#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 db_begin();
int db_commit();
int db_connect();
int db_disconnect();
int db_rollback();
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, int);
int /*<<< orphan*/ free(char *);
int getreply_text(char *, char *, char **);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdin;
scalar_t__ strlen(char *);
char *strtok(char *, char *);
int main(int argc, char *argv[]) {
  char buffer[1024];
  char *name;
  char *text;
  char *reply;
  int ret;
  int fail = 0;
  if (argc != 2 && argc != 3) {
    printf("Brain access for responses\n");
    printf("Usage: %s <name> [text]\n", argv[0]);
    printf("  Text will be read from stdin if not specified\n");
    return 1;
  }
  name = argv[1];
  text = argc == 3 ? argv[2] : NULL;
  ret = db_connect();
  if (ret) {
    fprintf(stderr, "<Unable to connect to database (%d)>\n", ret);
    return 1;
  }
  ret = db_begin();
  if (ret) {
    fprintf(stderr, "<Unable to begin database transaction (%d)>\n", ret);
    return 1;
  }
  while (argc == 2 || text != NULL) {
    if (text == NULL) {
      if (fgets(buffer, 1024, stdin) == NULL) {
        break;
      } else {
        text = strtok(buffer, "\r\n");
      }
    }
    if (text != NULL && strlen(text) == 0)
      text = NULL;
    reply = NULL;
    ret = getreply_text(name, text, &reply);
    if (ret) {
      fprintf(stderr, "<Unable to get reply for text (%d)>\n", ret);
      fail = 1;
      break;
    } else {
      printf("%s\n", reply);
      free(reply);
      reply = NULL;
    }
    text = NULL;
  }
  if (fail) {
    ret = db_rollback();
    if (ret) {
      fprintf(stderr, "<Unable to rollback database transaction (%d)>\n", ret);
      return 1;
    }
  } else {
    ret = db_commit();
    if (ret) {
      fprintf(stderr, "<Unable to commit database transaction (%d)>\n", ret);
      return 1;
    }
  }
  ret = db_disconnect();
  if (ret) {
    fprintf(stderr, "<Unable to disconnect from database (%d)>\n", ret);
    return 1;
  }
  return fail ? 1 : 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x440,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x430(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     1234 <main+0x74>
cmpl   $0x3,-0x8(%rbp)
je     1234 <main+0x74>
lea    0xe02(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe09(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    0xe14(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    154d <main+0x38d>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x418(%rbp)
cmpl   $0x3,-0x8(%rbp)
jne    1261 <main+0xa1>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x438(%rbp)
jmp    126f <main+0xaf>
xor    %eax,%eax
mov    %rax,-0x438(%rbp)
jmp    126f <main+0xaf>
mov    -0x438(%rbp),%rax
mov    %rax,-0x420(%rbp)
mov    $0x0,%al
call   10e0 <db_connect@plt>
mov    %eax,-0x42c(%rbp)
cmpl   $0x0,-0x42c(%rbp)
je     12be <main+0xfe>
mov    0x2d3a(%rip),%rax
mov    (%rax),%edi
mov    -0x42c(%rbp),%edx
lea    0xdb9(%rip),%rsi
call   1090 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    154d <main+0x38d>
mov    $0x0,%al
call   1040 <db_begin@plt>
mov    %eax,-0x42c(%rbp)
cmpl   $0x0,-0x42c(%rbp)
je     12ff <main+0x13f>
mov    0x2cf9(%rip),%rax
mov    (%rax),%edi
mov    -0x42c(%rbp),%edx
lea    0xd9e(%rip),%rsi
call   1090 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    154d <main+0x38d>
jmp    1304 <main+0x144>
mov    $0x1,%al
cmpl   $0x2,-0x8(%rbp)
mov    %al,-0x439(%rbp)
je     1327 <main+0x167>
cmpq   $0x0,-0x420(%rbp)
setne  %al
mov    %al,-0x439(%rbp)
mov    -0x439(%rbp),%al
test   $0x1,%al
jne    133a <main+0x17a>
jmp    145d <main+0x29d>
cmpq   $0x0,-0x420(%rbp)
jne    1390 <main+0x1d0>
lea    -0x410(%rbp),%rdi
mov    0x2c92(%rip),%rax
mov    (%rax),%edx
mov    $0x400,%esi
call   1080 <fgets@plt>
cmp    $0x0,%rax
jne    1371 <main+0x1b1>
jmp    145d <main+0x29d>
lea    -0x410(%rbp),%rdi
lea    0xd3a(%rip),%rsi
call   10c0 <strtok@plt>
mov    %rax,-0x420(%rbp)
jmp    1390 <main+0x1d0>
cmpq   $0x0,-0x420(%rbp)
je     13bf <main+0x1ff>
mov    -0x420(%rbp),%rdi
call   1060 <strlen@plt>
cmp    $0x0,%rax
jne    13bf <main+0x1ff>
movq   $0x0,-0x420(%rbp)
movq   $0x0,-0x428(%rbp)
mov    -0x418(%rbp),%rdi
mov    -0x420(%rbp),%rsi
lea    -0x428(%rbp),%rdx
call   1050 <getreply_text@plt>
mov    %eax,-0x42c(%rbp)
cmpl   $0x0,-0x42c(%rbp)
je     1421 <main+0x261>
mov    0x2bda(%rip),%rax
mov    (%rax),%edi
mov    -0x42c(%rbp),%edx
lea    0xcaf(%rip),%rsi
call   1090 <fprintf@plt>
movl   $0x1,-0x430(%rbp)
jmp    145d <main+0x29d>
mov    -0x428(%rbp),%rsi
lea    0xcb2(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x428(%rbp),%rdi
call   1030 <free@plt>
movq   $0x0,-0x428(%rbp)
movq   $0x0,-0x420(%rbp)
jmp    1304 <main+0x144>
cmpl   $0x0,-0x430(%rbp)
je     14b0 <main+0x2f0>
mov    $0x0,%al
call   10d0 <db_rollback@plt>
mov    %eax,-0x42c(%rbp)
cmpl   $0x0,-0x42c(%rbp)
je     14ab <main+0x2eb>
mov    0x2b4d(%rip),%rax
mov    (%rax),%edi
mov    -0x42c(%rbp),%edx
lea    0xc4b(%rip),%rsi
call   1090 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    154d <main+0x38d>
jmp    14f6 <main+0x336>
mov    $0x0,%al
call   10b0 <db_commit@plt>
mov    %eax,-0x42c(%rbp)
cmpl   $0x0,-0x42c(%rbp)
je     14f1 <main+0x331>
mov    0x2b07(%rip),%rax
mov    (%rax),%edi
mov    -0x42c(%rbp),%edx
lea    0xc35(%rip),%rsi
call   1090 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    154d <main+0x38d>
jmp    14f6 <main+0x336>
mov    $0x0,%al
call   10a0 <db_disconnect@plt>
mov    %eax,-0x42c(%rbp)
cmpl   $0x0,-0x42c(%rbp)
je     1537 <main+0x377>
mov    0x2ac1(%rip),%rax
mov    (%rax),%edi
mov    -0x42c(%rbp),%edx
lea    0xc1d(%rip),%rsi
call   1090 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    154d <main+0x38d>
mov    -0x430(%rbp),%edx
xor    %eax,%eax
mov    $0x1,%ecx
cmp    $0x0,%edx
cmovne %ecx,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x440,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x418,%rsp
mov    %rsi,%rbp
mov    %edi,%eax
and    $0xfffffffe,%eax
cmp    $0x2,%eax
jne    11e8 <main+0x28>
mov    %edi,%r15d
cmp    $0x3,%edi
jne    1217 <main+0x57>
mov    0x10(%rbp),%rbx
jmp    1219 <main+0x59>
lea    0xf2e(%rip),%rdi
call   1060 <puts@plt>
mov    0x0(%rbp),%rsi
lea    0xe01(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
lea    0xf2b(%rip),%rdi
call   1060 <puts@plt>
jmp    1376 <main+0x1b6>
xor    %ebx,%ebx
mov    0x8(%rbp),%r14
xor    %eax,%eax
call   10e0 <db_connect@plt>
test   %eax,%eax
je     123d <main+0x7d>
mov    0x2da9(%rip),%rcx
mov    (%rcx),%edi
lea    0xde1(%rip),%rsi
jmp    136f <main+0x1af>
xor    %eax,%eax
call   1040 <db_begin@plt>
test   %eax,%eax
je     125d <main+0x9d>
mov    0x2d89(%rip),%rcx
mov    (%rcx),%edi
lea    0xde7(%rip),%rsi
jmp    136f <main+0x1af>
cmp    $0x2,%r15d
je     12c0 <main+0x100>
test   %rbx,%rbx
jne    12c0 <main+0x100>
xor    %ebx,%ebx
xor    %eax,%eax
call   10b0 <db_commit@plt>
test   %eax,%eax
je     1354 <main+0x194>
mov    0x2d58(%rip),%rcx
mov    (%rcx),%edi
lea    0xe3b(%rip),%rsi
jmp    136f <main+0x1af>
xchg   %ax,%ax
mov    0x8(%rsp),%rdi
call   1060 <puts@plt>
mov    0x8(%rsp),%rdi
call   1030 <free@plt>
xor    %ebx,%ebx
movq   $0x0,0x8(%rsp)
cmp    $0x2,%r15d
je     12c0 <main+0x100>
jmp    1268 <main+0xa8>
xor    %esi,%esi
jmp    1304 <main+0x144>
nopl   0x0(%rax,%rax,1)
test   %rbx,%rbx
jne    12fb <main+0x13b>
mov    0x2d1c(%rip),%rax
mov    (%rax),%edx
lea    0x10(%rsp),%rdi
mov    $0x400,%esi
call   1080 <fgets@plt>
test   %rax,%rax
je     1268 <main+0xa8>
lea    0xd83(%rip),%rsi
lea    0x10(%rsp),%rdi
call   10c0 <strtok@plt>
mov    %rax,%rbx
test   %rax,%rax
je     12b7 <main+0xf7>
xor    %esi,%esi
cmpb   $0x0,(%rbx)
cmovne %rbx,%rsi
movq   $0x0,0x8(%rsp)
lea    0x8(%rsp),%rdx
mov    %r14,%rdi
call   1050 <getreply_text@plt>
test   %eax,%eax
je     1290 <main+0xd0>
mov    0x2caf(%rip),%rbx
mov    (%rbx),%edi
lea    0xd3d(%rip),%rsi
mov    %eax,%edx
call   1090 <fprintf@plt>
xor    %eax,%eax
call   10d0 <db_rollback@plt>
test   %eax,%eax
je     134f <main+0x18f>
mov    (%rbx),%edi
lea    0xd47(%rip),%rsi
jmp    136f <main+0x1af>
mov    $0x1,%ebx
xor    %eax,%eax
call   10a0 <db_disconnect@plt>
test   %eax,%eax
je     137b <main+0x1bb>
mov    0x2c72(%rip),%rcx
mov    (%rcx),%edi
lea    0xd83(%rip),%rsi
mov    %eax,%edx
call   1090 <fprintf@plt>
mov    $0x1,%ebx
mov    %ebx,%eax
add    $0x418,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [28 x i8] c"Brain access for responses\0A\00"
@.str.1 = [25 x i8] c"Usage: %s <name> [text]\0A\00"
@.str.2 = [49 x i8] c" Text will be read from stdin if not specified\0A\00"
@stderr = global i32 0
@.str.3 = [38 x i8] c"<Unable to connect to database (%d)>\0A\00"
@.str.4 = [45 x i8] c"<Unable to begin database transaction (%d)>\0A\00"
@stdin = global i32 0
@.str.5 = [3 x i8] c"\0D\0A\00"
@.str.6 = [37 x i8] c"<Unable to get reply for text (%d)>\0A\00"
@.str.7 = [4 x i8] c"%s\0A\00"
@.str.8 = [48 x i8] c"<Unable to rollback database transaction (%d)>\0A\00"
@.str.9 = [46 x i8] c"<Unable to commit database transaction (%d)>\0A\00"
@.str.10 = [43 x i8] c"<Unable to disconnect from database (%d)>\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [1024 x i8]
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i32
%11 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %11
%12 = load i32, i32* %4
%13 = icmp ne i32 %12, 2
br i1 %13, label %14, label %24
14: ; preds = %2
%15 = load i32, i32* %4
%16 = icmp ne i32 %15, 3
br i1 %16, label %17, label %24
17: ; preds = %14
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0))
%19 = load i8**, i8*** %5
%20 = getelementptr inbounds i8*, i8** %19, i64 0
%21 = load i8*, i8** %20
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i8* %21)
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.2, i64 0, i64 0))
store i32 1, i32* %3
br label %132
24: ; preds = %14, %2
%25 = load i8**, i8*** %5
%26 = getelementptr inbounds i8*, i8** %25, i64 1
%27 = load i8*, i8** %26
store i8* %27, i8** %7
%28 = load i32, i32* %4
%29 = icmp eq i32 %28, 3
br i1 %29, label %30, label %34
30: ; preds = %24
%31 = load i8**, i8*** %5
%32 = getelementptr inbounds i8*, i8** %31, i64 2
%33 = load i8*, i8** %32
br label %35
34: ; preds = %24
br label %35
35: ; preds = %34, %30
%36 = phi i8* [ %33, %30 ], [ null, %34 ]
store i8* %36, i8** %8
%37 = call i32 (...) @db_connect()
store i32 %37, i32* %10
%38 = load i32, i32* %10
%39 = icmp ne i32 %38, 0
br i1 %39, label %40, label %44
40: ; preds = %35
%41 = load i32, i32* @stderr
%42 = load i32, i32* %10
%43 = call i32 @fprintf(i32 %41, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.3, i64 0, i64 0), i32 %42)
store i32 1, i32* %3
br label %132
44: ; preds = %35
%45 = call i32 (...) @db_begin()
store i32 %45, i32* %10
%46 = load i32, i32* %10
%47 = icmp ne i32 %46, 0
br i1 %47, label %48, label %52
48: ; preds = %44
%49 = load i32, i32* @stderr
%50 = load i32, i32* %10
%51 = call i32 @fprintf(i32 %49, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.4, i64 0, i64 0), i32 %50)
store i32 1, i32* %3
br label %132
52: ; preds = %44
br label %53
53: ; preds = %97, %52
%54 = load i32, i32* %4
%55 = icmp eq i32 %54, 2
br i1 %55, label %59, label %56
56: ; preds = %53
%57 = load i8*, i8** %8
%58 = icmp ne i8* %57, null
br label %59
59: ; preds = %56, %53
%60 = phi i1 [ true, %53 ], [ %58, %56 ]
br i1 %60, label %61, label %98
61: ; preds = %59
%62 = load i8*, i8** %8
%63 = icmp eq i8* %62, null
br i1 %63, label %64, label %74
64: ; preds = %61
%65 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%66 = load i32, i32* @stdin
%67 = call i32* @fgets(i8* %65, i32 1024, i32 %66)
%68 = icmp eq i32* %67, null
br i1 %68, label %69, label %70
69: ; preds = %64
br label %98
70: ; preds = %64
%71 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%72 = call i8* @strtok(i8* %71, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
store i8* %72, i8** %8
br label %73
73: ; preds = %70
br label %74
74: ; preds = %73, %61
%75 = load i8*, i8** %8
%76 = icmp ne i8* %75, null
br i1 %76, label %77, label %82
77: ; preds = %74
%78 = load i8*, i8** %8
%79 = call i64 @strlen(i8* %78)
%80 = icmp eq i64 %79, 0
br i1 %80, label %81, label %82
81: ; preds = %77
store i8* null, i8** %8
br label %82
82: ; preds = %81, %77, %74
store i8* null, i8** %9
%83 = load i8*, i8** %7
%84 = load i8*, i8** %8
%85 = call i32 @getreply_text(i8* %83, i8* %84, i8** %9)
store i32 %85, i32* %10
%86 = load i32, i32* %10
%87 = icmp ne i32 %86, 0
br i1 %87, label %88, label %92
88: ; preds = %82
%89 = load i32, i32* @stderr
%90 = load i32, i32* %10
%91 = call i32 @fprintf(i32 %89, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.6, i64 0, i64 0), i32 %90)
store i32 1, i32* %11
br label %98
92: ; preds = %82
%93 = load i8*, i8** %9
%94 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0), i8* %93)
%95 = load i8*, i8** %9
%96 = call i32 @free(i8* %95)
store i8* null, i8** %9
br label %97
97: ; preds = %92
store i8* null, i8** %8
br label %53
98: ; preds = %88, %69, %59
%99 = load i32, i32* %11
%100 = icmp ne i32 %99, 0
br i1 %100, label %101, label %110
101: ; preds = %98
%102 = call i32 (...) @db_rollback()
store i32 %102, i32* %10
%103 = load i32, i32* %10
%104 = icmp ne i32 %103, 0
br i1 %104, label %105, label %109
105: ; preds = %101
%106 = load i32, i32* @stderr
%107 = load i32, i32* %10
%108 = call i32 @fprintf(i32 %106, i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.8, i64 0, i64 0), i32 %107)
store i32 1, i32* %3
br label %132
109: ; preds = %101
br label %119
110: ; preds = %98
%111 = call i32 (...) @db_commit()
store i32 %111, i32* %10
%112 = load i32, i32* %10
%113 = icmp ne i32 %112, 0
br i1 %113, label %114, label %118
114: ; preds = %110
%115 = load i32, i32* @stderr
%116 = load i32, i32* %10
%117 = call i32 @fprintf(i32 %115, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.9, i64 0, i64 0), i32 %116)
store i32 1, i32* %3
br label %132
118: ; preds = %110
br label %119
119: ; preds = %118, %109
%120 = call i32 (...) @db_disconnect()
store i32 %120, i32* %10
%121 = load i32, i32* %10
%122 = icmp ne i32 %121, 0
br i1 %122, label %123, label %127
123: ; preds = %119
%124 = load i32, i32* @stderr
%125 = load i32, i32* %10
%126 = call i32 @fprintf(i32 %124, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.10, i64 0, i64 0), i32 %125)
store i32 1, i32* %3
br label %132
127: ; preds = %119
%128 = load i32, i32* %11
%129 = icmp ne i32 %128, 0
%130 = zext i1 %129 to i64
%131 = select i1 %129, i32 1, i32 0
store i32 %131, i32* %3
br label %132
132: ; preds = %127, %123, %114, %105, %48, %40, %17
%133 = load i32, i32* %3
ret i32 %133
}

LLVM IR (-O2):
@.str.1 = [25 x i8] c"Usage: %s <name> [text]\0A\00"
@stderr = global i32 0
@.str.3 = [38 x i8] c"<Unable to connect to database (%d)>\0A\00"
@.str.4 = [45 x i8] c"<Unable to begin database transaction (%d)>\0A\00"
@stdin = global i32 0
@.str.5 = [3 x i8] c"\0D\0A\00"
@.str.6 = [37 x i8] c"<Unable to get reply for text (%d)>\0A\00"
@.str.8 = [48 x i8] c"<Unable to rollback database transaction (%d)>\0A\00"
@.str.9 = [46 x i8] c"<Unable to commit database transaction (%d)>\0A\00"
@.str.10 = [43 x i8] c"<Unable to disconnect from database (%d)>\0A\00"
@str = [27 x i8] c"Brain access for responses\00"
@str.11 = [48 x i8] c" Text will be read from stdin if not specified\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [1024 x i8]
%4 = alloca i8*
%5 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%6 = bitcast i8** %4 to i8*
%7 = and i32 %0, -2
%8 = icmp eq i32 %7, 2
br i1 %8, label %14, label %9
9: ; preds = %2
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str, i64 0, i64 0))
%11 = load i8*, i8** %1
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i8* %11)
%13 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([48 x i8], [48 x i8]* @str.11, i64 0, i64 0))
br label %83
14: ; preds = %2
%15 = getelementptr inbounds i8*, i8** %1, i64 1
%16 = load i8*, i8** %15
%17 = icmp eq i32 %0, 3
br i1 %17, label %18, label %21
18: ; preds = %14
%19 = getelementptr inbounds i8*, i8** %1, i64 2
%20 = load i8*, i8** %19
br label %21
21: ; preds = %14, %18
%22 = phi i8* [ %20, %18 ], [ null, %14 ]
%23 = tail call i32 (...) @db_connect()
%24 = icmp eq i32 %23, 0
br i1 %24, label %28, label %25
25: ; preds = %21
%26 = load i32, i32* @stderr
%27 = tail call i32 @fprintf(i32 %26, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.3, i64 0, i64 0), i32 %23)
br label %83
28: ; preds = %21
%29 = tail call i32 (...) @db_begin()
%30 = icmp eq i32 %29, 0
br i1 %30, label %31, label %35
31: ; preds = %28
%32 = icmp eq i32 %0, 2
%33 = icmp ne i8* %22, null
%34 = select i1 %32, i1 true, i1 %33
br i1 %34, label %38, label %70
35: ; preds = %28
%36 = load i32, i32* @stderr
%37 = tail call i32 @fprintf(i32 %36, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.4, i64 0, i64 0), i32 %29)
br label %83
38: ; preds = %31, %57
%39 = phi i8* [ null, %57 ], [ %22, %31 ]
%40 = icmp eq i8* %39, null
br i1 %40, label %41, label %48
41: ; preds = %38
%42 = load i32, i32* @stdin
%43 = call i32* @fgets(i8* %5, i32 1024, i32 %42)
%44 = icmp eq i32* %43, null
br i1 %44, label %70, label %45
45: ; preds = %41
%46 = call i8* @strtok(i8* %5, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
%47 = icmp eq i8* %46, null
br i1 %47, label %53, label %48
48: ; preds = %38, %45
%49 = phi i8* [ %46, %45 ], [ %39, %38 ]
%50 = load i8, i8* %49
%51 = icmp eq i8 %50, 0
%52 = select i1 %51, i8* null, i8* %49
br label %53
53: ; preds = %48, %45
%54 = phi i8* [ %52, %48 ], [ null, %45 ]
store i8* null, i8** %4
%55 = call i32 @getreply_text(i8* %16, i8* %54, i8** %4)
%56 = icmp eq i32 %55, 0
br i1 %56, label %57, label %62
57: ; preds = %53
%58 = load i8*, i8** %4
%59 = call i32 @puts(i8* dereferenceable(1) %58)
%60 = load i8*, i8** %4
%61 = call i32 @free(i8* %60)
store i8* null, i8** %4
br i1 %32, label %38, label %70
62: ; preds = %53
%63 = load i32, i32* @stderr
%64 = call i32 @fprintf(i32 %63, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.6, i64 0, i64 0), i32 %55)
%65 = call i32 (...) @db_rollback()
%66 = icmp eq i32 %65, 0
br i1 %66, label %76, label %67
67: ; preds = %62
%68 = load i32, i32* @stderr
%69 = call i32 @fprintf(i32 %68, i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.8, i64 0, i64 0), i32 %65)
br label %83
70: ; preds = %57, %41, %31
%71 = call i32 (...) @db_commit()
%72 = icmp eq i32 %71, 0
br i1 %72, label %76, label %73
73: ; preds = %70
%74 = load i32, i32* @stderr
%75 = call i32 @fprintf(i32 %74, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.9, i64 0, i64 0), i32 %71)
br label %83
76: ; preds = %70, %62
%77 = phi i32 [ 0, %70 ], [ 1, %62 ]
%78 = call i32 (...) @db_disconnect()
%79 = icmp eq i32 %78, 0
br i1 %79, label %83, label %80
80: ; preds = %76
%81 = load i32, i32* @stderr
%82 = call i32 @fprintf(i32 %81, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.10, i64 0, i64 0), i32 %78)
br label %83
83: ; preds = %76, %80, %73, %67, %35, %25, %9
%84 = phi i32 [ 1, %9 ], [ 1, %25 ], [ 1, %35 ], [ 1, %67 ], [ 1, %80 ], [ 1, %73 ], [ %77, %76 ]
ret i32 %84
}