#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
scalar_t__ isdigit(char const);
scalar_t__ strncmp(char const *, char *, int);
int logger_line_log_level(int tags_count, const char **tags) {
  int i;
  for (i = 0; i < tags_count; i++) {
    if (strncmp(tags[i], "log", 3) == 0) {
      if (isdigit(tags[i][3])) {
        return (tags[i][3] - '0');
      }
    }
  }
  return 9;
}


x86 assembly (clang, -O0):
<logger_line_log_level>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11bb <logger_line_log_level+0x9b>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xeab(%rip),%rsi
mov    $0x3,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    11a8 <logger_line_log_level+0x88>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movsbl 0x3(%rax),%edi
call   1040 <isdigit@plt>
cmp    $0x0,%rax
je     11a3 <logger_line_log_level+0x83>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movsbl 0x3(%rax),%eax
sub    $0x30,%eax
mov    %eax,-0x4(%rbp)
jmp    11c2 <logger_line_log_level+0xa2>
jmp    11a8 <logger_line_log_level+0x88>
jmp    11ad <logger_line_log_level+0x8d>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1136 <logger_line_log_level+0x16>
movl   $0x9,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<logger_line_log_level>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    $0x9,%r14d
test   %edi,%edi
jle    118e <logger_line_log_level+0x6e>
mov    %rsi,%rbx
mov    %edi,%r12d
xor    %ebp,%ebp
lea    0xebf(%rip),%r15
jmp    1159 <logger_line_log_level+0x39>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
add    $0x1,%rbp
cmp    %rbp,%r12
je     118e <logger_line_log_level+0x6e>
mov    (%rbx,%rbp,8),%rdi
mov    %r15,%rsi
mov    $0x3,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
jne    1150 <logger_line_log_level+0x30>
mov    (%rbx,%rbp,8),%rax
movsbl 0x3(%rax),%edi
call   1040 <isdigit@plt>
test   %rax,%rax
je     1150 <logger_line_log_level+0x30>
mov    (%rbx,%rbp,8),%rax
movsbl 0x3(%rax),%r14d
add    $0xffffffd0,%r14d
mov    %r14d,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"log\00"
define i32 @logger_line_log_level(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %6
br label %7
7: ; preds = %41, %2
%8 = load i32, i32* %6
%9 = load i32, i32* %4
%10 = icmp slt i32 %8, %9
br i1 %10, label %11, label %44
11: ; preds = %7
%12 = load i8**, i8*** %5
%13 = load i32, i32* %6
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds i8*, i8** %12, i64 %14
%16 = load i8*, i8** %15
%17 = call i64 @strncmp(i8* %16, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 3)
%18 = icmp eq i64 %17, 0
br i1 %18, label %19, label %40
19: ; preds = %11
%20 = load i8**, i8*** %5
%21 = load i32, i32* %6
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds i8*, i8** %20, i64 %22
%24 = load i8*, i8** %23
%25 = getelementptr inbounds i8, i8* %24, i64 3
%26 = load i8, i8* %25
%27 = call i64 @isdigit(i8 signext %26)
%28 = icmp ne i64 %27, 0
br i1 %28, label %29, label %39
29: ; preds = %19
%30 = load i8**, i8*** %5
%31 = load i32, i32* %6
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds i8*, i8** %30, i64 %32
%34 = load i8*, i8** %33
%35 = getelementptr inbounds i8, i8* %34, i64 3
%36 = load i8, i8* %35
%37 = sext i8 %36 to i32
%38 = sub nsw i32 %37, 48
store i32 %38, i32* %3
br label %45
39: ; preds = %19
br label %40
40: ; preds = %39, %11
br label %41
41: ; preds = %40
%42 = load i32, i32* %6
%43 = add nsw i32 %42, 1
store i32 %43, i32* %6
br label %7
44: ; preds = %7
store i32 9, i32* %3
br label %45
45: ; preds = %44, %29
%46 = load i32, i32* %3
ret i32 %46
}

LLVM IR (-O2):
@.str = [4 x i8] c"log\00"
define i32 @logger_line_log_level(i32 %0, i8** nocapture %1) {
%3 = icmp sgt i32 %0, 0
br i1 %3, label %4, label %27
4: ; preds = %2
%5 = zext i32 %0 to i64
br label %6
6: ; preds = %4, %24
%7 = phi i64 [ 0, %4 ], [ %25, %24 ]
%8 = getelementptr inbounds i8*, i8** %1, i64 %7
%9 = load i8*, i8** %8
%10 = tail call i64 @strncmp(i8* %9, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 3)
%11 = icmp eq i64 %10, 0
br i1 %11, label %12, label %24
12: ; preds = %6
%13 = load i8*, i8** %8
%14 = getelementptr inbounds i8, i8* %13, i64 3
%15 = load i8, i8* %14
%16 = tail call i64 @isdigit(i8 signext %15)
%17 = icmp eq i64 %16, 0
br i1 %17, label %24, label %18
18: ; preds = %12
%19 = load i8*, i8** %8
%20 = getelementptr inbounds i8, i8* %19, i64 3
%21 = load i8, i8* %20
%22 = sext i8 %21 to i32
%23 = add nsw i32 %22, -48
br label %27
24: ; preds = %6, %12
%25 = add nuw nsw i64 %7, 1
%26 = icmp eq i64 %25, %5
br i1 %26, label %27, label %6
27: ; preds = %24, %2, %18
%28 = phi i32 [ %23, %18 ], [ 9, %2 ], [ 9, %24 ]
ret i32 %28
}