#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 */
int atoi(char *);
scalar_t__ regmatchInsensitive(char *, char *);
int /*<<< orphan*/ slog(int, char *, char *);
int /*<<< orphan*/ strlen(char *);
int getLogLevel(char *string) {
  int logLevel = 1;
  if (regmatchInsensitive(string, "^logLevel=[1-9]+$")) {
    string += strlen("logLevel=");
    logLevel = atoi(string);
    logLevel = logLevel % 4;
  } else {
    slog(1, "... problems reading the log level: the line %s is not correct\n",
         string);
  }
  return logLevel;
}


x86 assembly (clang, -O0):
<getLogLevel>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x1,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xea2(%rip),%rsi
call   1060 <regmatchInsensitive@plt>
cmp    $0x0,%rax
je     11a8 <getLogLevel+0x68>
lea    0xe9e(%rip),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x8(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <atoi@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
mov    %edx,-0xc(%rbp)
jmp    11bd <getLogLevel+0x7d>
mov    -0x8(%rbp),%rdx
mov    $0x1,%edi
lea    0xe64(%rip),%rsi
call   1040 <slog@plt>
mov    -0xc(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getLogLevel>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
lea    0xeb2(%rip),%rsi
call   1060 <regmatchInsensitive@plt>
test   %rax,%rax
je     1182 <getLogLevel+0x42>
lea    0xeb3(%rip),%rdi
call   1030 <strlen@plt>
cltq
add    %rax,%r14
mov    %r14,%rdi
call   1050 <atoi@plt>
mov    %eax,%ebx
lea    0x3(%rbx),%eax
test   %ebx,%ebx
cmovns %ebx,%eax
and    $0xfffffffc,%eax
sub    %eax,%ebx
jmp    119b <getLogLevel+0x5b>
lea    0xe93(%rip),%rsi
mov    $0x1,%ebx
mov    $0x1,%edi
mov    %r14,%rdx
call   1040 <slog@plt>
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [18 x i8] c"^logLevel=[1-9]+$\00"
@.str.1 = [10 x i8] c"logLevel=\00"
@.str.2 = [64 x i8] c"... problems reading the log level: the line %s is not correct\0A\00"
define i32 @getLogLevel(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
store i8* %0, i8** %2
store i32 1, i32* %3
%4 = load i8*, i8** %2
%5 = call i64 @regmatchInsensitive(i8* %4, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%6 = icmp ne i64 %5, 0
br i1 %6, label %7, label %16
7: ; preds = %1
%8 = call i32 @strlen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
%9 = load i8*, i8** %2
%10 = sext i32 %8 to i64
%11 = getelementptr inbounds i8, i8* %9, i64 %10
store i8* %11, i8** %2
%12 = load i8*, i8** %2
%13 = call i32 @atoi(i8* %12)
store i32 %13, i32* %3
%14 = load i32, i32* %3
%15 = srem i32 %14, 4
store i32 %15, i32* %3
br label %19
16: ; preds = %1
%17 = load i8*, i8** %2
%18 = call i32 @slog(i32 1, i8* getelementptr inbounds ([64 x i8], [64 x i8]* @.str.2, i64 0, i64 0), i8* %17)
br label %19
19: ; preds = %16, %7
%20 = load i32, i32* %3
ret i32 %20
}

LLVM IR (-O2):
@.str = [18 x i8] c"^logLevel=[1-9]+$\00"
@.str.1 = [10 x i8] c"logLevel=\00"
@.str.2 = [64 x i8] c"... problems reading the log level: the line %s is not correct\0A\00"
define i32 @getLogLevel(i8* %0) {
%2 = tail call i64 @regmatchInsensitive(i8* %0, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%3 = icmp eq i64 %2, 0
br i1 %3, label %10, label %4
4: ; preds = %1
%5 = tail call i32 @strlen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
%6 = sext i32 %5 to i64
%7 = getelementptr inbounds i8, i8* %0, i64 %6
%8 = tail call i32 @atoi(i8* %7)
%9 = srem i32 %8, 4
br label %12
10: ; preds = %1
%11 = tail call i32 @slog(i32 1, i8* getelementptr inbounds ([64 x i8], [64 x i8]* @.str.2, i64 0, i64 0), i8* %0)
br label %12
12: ; preds = %10, %4
%13 = phi i32 [ %9, %4 ], [ 1, %10 ]
ret i32 %13
}