#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 getLogFileToKeep(char *string) {
  int keep = 3;
  if (regmatchInsensitive(string, "^logFileToKeep=[1-9]+$")) {
    string += strlen("logFileToKeep=");
    keep = atoi(string);
  } else {
    slog(1,
         "... problems reading the log files to keep: the line %s is not "
         "correct\n",
         string);
  }
  return keep;
}


x86 assembly (clang, -O0):
<getLogFileToKeep>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x3,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xea2(%rip),%rsi
call   1060 <regmatchInsensitive@plt>
cmp    $0x0,%rax
je     119a <getLogFileToKeep+0x5a>
lea    0xea3(%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)
jmp    11af <getLogFileToKeep+0x6f>
mov    -0x8(%rbp),%rdx
mov    $0x1,%edi
lea    0xe7c(%rip),%rsi
call   1040 <slog@plt>
mov    -0xc(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getLogFileToKeep>:
push   %rbx
mov    %rdi,%rbx
lea    0xeb5(%rip),%rsi
call   1060 <regmatchInsensitive@plt>
test   %rax,%rax
je     116f <getLogFileToKeep+0x2f>
lea    0xebb(%rip),%rdi
call   1030 <strlen@plt>
cltq
add    %rax,%rbx
mov    %rbx,%rdi
pop    %rbx
jmp    1050 <atoi@plt>
lea    0xeb0(%rip),%rsi
mov    $0x1,%edi
mov    %rbx,%rdx
call   1040 <slog@plt>
mov    $0x3,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [23 x i8] c"^logFileToKeep=[1-9]+$\00"
@.str.1 = [15 x i8] c"logFileToKeep=\00"
@.str.2 = [72 x i8] c"... problems reading the log files to keep: the line %s is not correct\0A\00"
define i32 @getLogFileToKeep(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
store i8* %0, i8** %2
store i32 3, i32* %3
%4 = load i8*, i8** %2
%5 = call i64 @regmatchInsensitive(i8* %4, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
%6 = icmp ne i64 %5, 0
br i1 %6, label %7, label %14
7: ; preds = %1
%8 = call i32 @strlen(i8* getelementptr inbounds ([15 x i8], [15 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
br label %17
14: ; preds = %1
%15 = load i8*, i8** %2
%16 = call i32 @slog(i32 1, i8* getelementptr inbounds ([72 x i8], [72 x i8]* @.str.2, i64 0, i64 0), i8* %15)
br label %17
17: ; preds = %14, %7
%18 = load i32, i32* %3
ret i32 %18
}

LLVM IR (-O2):
@.str = [23 x i8] c"^logFileToKeep=[1-9]+$\00"
@.str.1 = [15 x i8] c"logFileToKeep=\00"
@.str.2 = [72 x i8] c"... problems reading the log files to keep: the line %s is not correct\0A\00"
define i32 @getLogFileToKeep(i8* %0) {
%2 = tail call i64 @regmatchInsensitive(i8* %0, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
%3 = icmp eq i64 %2, 0
br i1 %3, label %9, label %4
4: ; preds = %1
%5 = tail call i32 @strlen(i8* getelementptr inbounds ([15 x i8], [15 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)
br label %11
9: ; preds = %1
%10 = tail call i32 @slog(i32 1, i8* getelementptr inbounds ([72 x i8], [72 x i8]* @.str.2, i64 0, i64 0), i8* %0)
br label %11
11: ; preds = %9, %4
%12 = phi i32 [ %8, %4 ], [ 3, %9 ]
ret i32 %12
}