#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 executeSql(char *, int /*<<< orphan*/ *);
int setDbVersion(int);
int upgrade6() {
  int status = setDbVersion(6);
  if (status == 0) {
    return 0;
  }
  status = executeSql(
      "CREATE TABLE alert (id, name, active, bound, direction, amount)", NULL);
  if (status == 0) {
    return 0;
  }
  status = executeSql("CREATE TABLE interval (id, yr, mn, dy, wk, hr)", NULL);
  if (status == 0) {
    return 0;
  }
  status =
      executeSql("CREATE TABLE alert_interval (alert_id, interval_id)", NULL);
  if (status == 0) {
    return 0;
  }
  status = executeSql("CREATE INDEX idxDataTs ON data(ts)", NULL);
  if (status == 0) {
    return 0;
  }
  return 1;
}


x86 assembly (clang, -O0):
<upgrade6>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x6,%edi
call   1040 <setDbVersion@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jne    114b <upgrade6+0x2b>
movl   $0x0,-0x4(%rbp)
jmp    11f6 <upgrade6+0xd6>
lea    0xeae(%rip),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1030 <executeSql@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jne    1174 <upgrade6+0x54>
movl   $0x0,-0x4(%rbp)
jmp    11f6 <upgrade6+0xd6>
lea    0xec5(%rip),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1030 <executeSql@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jne    119d <upgrade6+0x7d>
movl   $0x0,-0x4(%rbp)
jmp    11f6 <upgrade6+0xd6>
lea    0xecb(%rip),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1030 <executeSql@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jne    11c6 <upgrade6+0xa6>
movl   $0x0,-0x4(%rbp)
jmp    11f6 <upgrade6+0xd6>
lea    0xed6(%rip),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1030 <executeSql@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jne    11ef <upgrade6+0xcf>
movl   $0x0,-0x4(%rbp)
jmp    11f6 <upgrade6+0xd6>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<upgrade6>:
push   %rbx
mov    $0x6,%edi
call   1040 <setDbVersion@plt>
test   %eax,%eax
je     1182 <upgrade6+0x62>
lea    0xeca(%rip),%rdi
xor    %ebx,%ebx
xor    %esi,%esi
call   1030 <executeSql@plt>
test   %eax,%eax
je     1184 <upgrade6+0x64>
lea    0xef6(%rip),%rdi
xor    %ebx,%ebx
xor    %esi,%esi
call   1030 <executeSql@plt>
test   %eax,%eax
je     1184 <upgrade6+0x64>
lea    0xf11(%rip),%rdi
xor    %ebx,%ebx
xor    %esi,%esi
call   1030 <executeSql@plt>
test   %eax,%eax
je     1184 <upgrade6+0x64>
lea    0xf31(%rip),%rdi
xor    %esi,%esi
call   1030 <executeSql@plt>
xor    %ebx,%ebx
test   %eax,%eax
setne  %bl
jmp    1184 <upgrade6+0x64>
xor    %ebx,%ebx
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [64 x i8] c"CREATE TABLE alert (id, name, active, bound, direction, amount)\00"
@.str.1 = [47 x i8] c"CREATE TABLE interval (id, yr, mn, dy, wk, hr)\00"
@.str.2 = [52 x i8] c"CREATE TABLE alert_interval (alert_id, interval_id)\00"
@.str.3 = [35 x i8] c"CREATE INDEX idxDataTs ON data(ts)\00"
define i32 @upgrade6() {
%1 = alloca i32
%2 = alloca i32
%3 = call i32 @setDbVersion(i32 6)
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 @executeSql(i8* getelementptr inbounds ([64 x i8], [64 x i8]* @.str, i64 0, i64 0), i32* null)
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 @executeSql(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.1, i64 0, i64 0), i32* null)
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 @executeSql(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.2, i64 0, i64 0), i32* null)
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 @executeSql(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.3, i64 0, i64 0), i32* null)
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 = [64 x i8] c"CREATE TABLE alert (id, name, active, bound, direction, amount)\00"
@.str.1 = [47 x i8] c"CREATE TABLE interval (id, yr, mn, dy, wk, hr)\00"
@.str.2 = [52 x i8] c"CREATE TABLE alert_interval (alert_id, interval_id)\00"
@.str.3 = [35 x i8] c"CREATE INDEX idxDataTs ON data(ts)\00"
define i32 @upgrade6() {
%1 = tail call i32 @setDbVersion(i32 6)
%2 = icmp eq i32 %1, 0
br i1 %2, label %16, label %3
3: ; preds = %0
%4 = tail call i32 @executeSql(i8* getelementptr inbounds ([64 x i8], [64 x i8]* @.str, i64 0, i64 0), i32* null)
%5 = icmp eq i32 %4, 0
br i1 %5, label %16, label %6
6: ; preds = %3
%7 = tail call i32 @executeSql(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.1, i64 0, i64 0), i32* null)
%8 = icmp eq i32 %7, 0
br i1 %8, label %16, label %9
9: ; preds = %6
%10 = tail call i32 @executeSql(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.2, i64 0, i64 0), i32* null)
%11 = icmp eq i32 %10, 0
br i1 %11, label %16, label %12
12: ; preds = %9
%13 = tail call i32 @executeSql(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.3, i64 0, i64 0), i32* null)
%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
}