#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 setConfigIntValue(char *, int);
int setDbVersion(int);
int upgrade2() {
  int status;
  status = setDbVersion(2);
  if (status == 0) {
    return 0;
  }
  status = setConfigIntValue("web.monitor_interval", 1000);
  if (status == 0) {
    return 0;
  }
  status = setConfigIntValue("web.summary_interval", 10000);
  if (status == 0) {
    return 0;
  }
  status = setConfigIntValue("web.history_interval", 10000);
  if (status == 0) {
    return 0;
  }
  status = setConfigIntValue("web.allow_remote", 0);
  if (status == 0) {
    return 0;
  }
  return 1;
}


x86 assembly (clang, -O0):
<upgrade2>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x2,%edi
call   1030 <setDbVersion@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jne    114b <upgrade2+0x2b>
movl   $0x0,-0x4(%rbp)
jmp    11f7 <upgrade2+0xd7>
lea    0xeae(%rip),%rdi
mov    $0x3e8,%esi
call   1040 <setConfigIntValue@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jne    1175 <upgrade2+0x55>
movl   $0x0,-0x4(%rbp)
jmp    11f7 <upgrade2+0xd7>
lea    0xe99(%rip),%rdi
mov    $0x2710,%esi
call   1040 <setConfigIntValue@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jne    119f <upgrade2+0x7f>
movl   $0x0,-0x4(%rbp)
jmp    11f7 <upgrade2+0xd7>
lea    0xe84(%rip),%rdi
mov    $0x2710,%esi
call   1040 <setConfigIntValue@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jne    11c9 <upgrade2+0xa9>
movl   $0x0,-0x4(%rbp)
jmp    11f7 <upgrade2+0xd7>
lea    0xe6f(%rip),%rdi
xor    %esi,%esi
call   1040 <setConfigIntValue@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jne    11f0 <upgrade2+0xd0>
movl   $0x0,-0x4(%rbp)
jmp    11f7 <upgrade2+0xd7>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<upgrade2>:
push   %rbx
mov    $0x2,%edi
call   1030 <setDbVersion@plt>
xor    %ebx,%ebx
test   %eax,%eax
je     1185 <upgrade2+0x65>
lea    0xec8(%rip),%rdi
mov    $0x3e8,%esi
call   1040 <setConfigIntValue@plt>
test   %eax,%eax
je     1185 <upgrade2+0x65>
lea    0xec8(%rip),%rdi
mov    $0x2710,%esi
call   1040 <setConfigIntValue@plt>
test   %eax,%eax
je     1185 <upgrade2+0x65>
lea    0xec8(%rip),%rdi
mov    $0x2710,%esi
call   1040 <setConfigIntValue@plt>
test   %eax,%eax
je     1185 <upgrade2+0x65>
lea    0xec8(%rip),%rdi
xor    %esi,%esi
call   1040 <setConfigIntValue@plt>
xor    %ebx,%ebx
test   %eax,%eax
setne  %bl
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [21 x i8] c"web.monitor_interval\00"
@.str.1 = [21 x i8] c"web.summary_interval\00"
@.str.2 = [21 x i8] c"web.history_interval\00"
@.str.3 = [17 x i8] c"web.allow_remote\00"
define i32 @upgrade2() {
%1 = alloca i32
%2 = alloca i32
%3 = call i32 @setDbVersion(i32 2)
store i32 %3, i32* %2
%4 = load i32, i32* %2
%5 = icmp eq i32 %4, 0
br i1 %5, label %6, label %7
6: ; preds = %0
store i32 0, i32* %1
br label %28
7: ; preds = %0
%8 = call i32 @setConfigIntValue(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i32 1000)
store i32 %8, i32* %2
%9 = load i32, i32* %2
%10 = icmp eq i32 %9, 0
br i1 %10, label %11, label %12
11: ; preds = %7
store i32 0, i32* %1
br label %28
12: ; preds = %7
%13 = call i32 @setConfigIntValue(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i32 10000)
store i32 %13, i32* %2
%14 = load i32, i32* %2
%15 = icmp eq i32 %14, 0
br i1 %15, label %16, label %17
16: ; preds = %12
store i32 0, i32* %1
br label %28
17: ; preds = %12
%18 = call i32 @setConfigIntValue(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i32 10000)
store i32 %18, i32* %2
%19 = load i32, i32* %2
%20 = icmp eq i32 %19, 0
br i1 %20, label %21, label %22
21: ; preds = %17
store i32 0, i32* %1
br label %28
22: ; preds = %17
%23 = call i32 @setConfigIntValue(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0), i32 0)
store i32 %23, i32* %2
%24 = load i32, i32* %2
%25 = icmp eq i32 %24, 0
br i1 %25, label %26, label %27
26: ; preds = %22
store i32 0, i32* %1
br label %28
27: ; preds = %22
store i32 1, i32* %1
br label %28
28: ; preds = %27, %26, %21, %16, %11, %6
%29 = load i32, i32* %1
ret i32 %29
}

LLVM IR (-O2):
@.str = [21 x i8] c"web.monitor_interval\00"
@.str.1 = [21 x i8] c"web.summary_interval\00"
@.str.2 = [21 x i8] c"web.history_interval\00"
@.str.3 = [17 x i8] c"web.allow_remote\00"
define i32 @upgrade2() {
%1 = tail call i32 @setDbVersion(i32 2)
%2 = icmp eq i32 %1, 0
br i1 %2, label %16, label %3
3: ; preds = %0
%4 = tail call i32 @setConfigIntValue(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i32 1000)
%5 = icmp eq i32 %4, 0
br i1 %5, label %16, label %6
6: ; preds = %3
%7 = tail call i32 @setConfigIntValue(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i32 10000)
%8 = icmp eq i32 %7, 0
br i1 %8, label %16, label %9
9: ; preds = %6
%10 = tail call i32 @setConfigIntValue(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i32 10000)
%11 = icmp eq i32 %10, 0
br i1 %11, label %16, label %12
12: ; preds = %9
%13 = tail call i32 @setConfigIntValue(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0), i32 0)
%14 = icmp ne i32 %13, 0
%15 = zext i1 %14 to i32
br label %16
16: ; preds = %12, %9, %6, %3, %0
%17 = phi i32 [ 0, %0 ], [ 0, %3 ], [ 0, %6 ], [ 0, %9 ], [ %15, %12 ]
ret i32 %17
}