#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 learn_text(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;
  int ret;
  int fail = 0;
  if (argc != 2 && argc != 3) {
    printf("Brain access for learning\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;
    ret = learn_text(name, text);
    if (ret) {
      fprintf(stderr, "<Unable to learn text (%d)>\n", ret);
      fail = 1;
      break;
    }
    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,-0x428(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     1224 <main+0x74>
cmpl   $0x3,-0x8(%rbp)
je     1224 <main+0x74>
lea    0xe12(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe18(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xe23(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    14ff <main+0x34f>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x418(%rbp)
cmpl   $0x3,-0x8(%rbp)
jne    1251 <main+0xa1>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x430(%rbp)
jmp    125f <main+0xaf>
xor    %eax,%eax
mov    %rax,-0x430(%rbp)
jmp    125f <main+0xaf>
mov    -0x430(%rbp),%rax
mov    %rax,-0x420(%rbp)
mov    $0x0,%al
call   10d0 <db_connect@plt>
mov    %eax,-0x424(%rbp)
cmpl   $0x0,-0x424(%rbp)
je     12ae <main+0xfe>
mov    0x2d4a(%rip),%rax
mov    (%rax),%edi
mov    -0x424(%rbp),%edx
lea    0xdc8(%rip),%rsi
call   1080 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    14ff <main+0x34f>
mov    $0x0,%al
call   1030 <db_begin@plt>
mov    %eax,-0x424(%rbp)
cmpl   $0x0,-0x424(%rbp)
je     12ef <main+0x13f>
mov    0x2d09(%rip),%rax
mov    (%rax),%edi
mov    -0x424(%rbp),%edx
lea    0xdad(%rip),%rsi
call   1080 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    14ff <main+0x34f>
jmp    12f4 <main+0x144>
mov    $0x1,%al
cmpl   $0x2,-0x8(%rbp)
mov    %al,-0x431(%rbp)
je     1317 <main+0x167>
cmpq   $0x0,-0x420(%rbp)
setne  %al
mov    %al,-0x431(%rbp)
mov    -0x431(%rbp),%al
test   $0x1,%al
jne    132a <main+0x17a>
jmp    140f <main+0x25f>
cmpq   $0x0,-0x420(%rbp)
jne    1380 <main+0x1d0>
lea    -0x410(%rbp),%rdi
mov    0x2ca2(%rip),%rax
mov    (%rax),%edx
mov    $0x400,%esi
call   1060 <fgets@plt>
cmp    $0x0,%rax
jne    1361 <main+0x1b1>
jmp    140f <main+0x25f>
lea    -0x410(%rbp),%rdi
lea    0xd49(%rip),%rsi
call   10b0 <strtok@plt>
mov    %rax,-0x420(%rbp)
jmp    1380 <main+0x1d0>
cmpq   $0x0,-0x420(%rbp)
je     13af <main+0x1ff>
mov    -0x420(%rbp),%rdi
call   1040 <strlen@plt>
cmp    $0x0,%rax
jne    13af <main+0x1ff>
movq   $0x0,-0x420(%rbp)
mov    -0x418(%rbp),%rdi
mov    -0x420(%rbp),%rsi
call   1070 <learn_text@plt>
mov    %eax,-0x424(%rbp)
cmpl   $0x0,-0x424(%rbp)
je     13ff <main+0x24f>
mov    0x2bfc(%rip),%rax
mov    (%rax),%edi
mov    -0x424(%rbp),%edx
lea    0xcd0(%rip),%rsi
call   1080 <fprintf@plt>
movl   $0x1,-0x428(%rbp)
jmp    140f <main+0x25f>
movq   $0x0,-0x420(%rbp)
jmp    12f4 <main+0x144>
cmpl   $0x0,-0x428(%rbp)
je     1462 <main+0x2b2>
mov    $0x0,%al
call   10c0 <db_rollback@plt>
mov    %eax,-0x424(%rbp)
cmpl   $0x0,-0x424(%rbp)
je     145d <main+0x2ad>
mov    0x2b9b(%rip),%rax
mov    (%rax),%edi
mov    -0x424(%rbp),%edx
lea    0xc8c(%rip),%rsi
call   1080 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    14ff <main+0x34f>
jmp    14a8 <main+0x2f8>
mov    $0x0,%al
call   10a0 <db_commit@plt>
mov    %eax,-0x424(%rbp)
cmpl   $0x0,-0x424(%rbp)
je     14a3 <main+0x2f3>
mov    0x2b55(%rip),%rax
mov    (%rax),%edi
mov    -0x424(%rbp),%edx
lea    0xc76(%rip),%rsi
call   1080 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    14ff <main+0x34f>
jmp    14a8 <main+0x2f8>
mov    $0x0,%al
call   1090 <db_disconnect@plt>
mov    %eax,-0x424(%rbp)
cmpl   $0x0,-0x424(%rbp)
je     14e9 <main+0x339>
mov    0x2b0f(%rip),%rax
mov    (%rax),%edi
mov    -0x424(%rbp),%edx
lea    0xc5e(%rip),%rsi
call   1080 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    14ff <main+0x34f>
mov    -0x428(%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   %r13
push   %r12
push   %rbx
sub    $0x408,%rsp
mov    %rsi,%rbp
mov    %edi,%eax
and    $0xfffffffe,%eax
cmp    $0x2,%eax
jne    11dc <main+0x2c>
mov    %edi,%r13d
cmp    $0x3,%edi
jne    1208 <main+0x58>
mov    0x10(%rbp),%rbx
jmp    120a <main+0x5a>
lea    0xf32(%rip),%rdi
call   1040 <puts@plt>
mov    0x0(%rbp),%rsi
lea    0xe0d(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xf2e(%rip),%rdi
call   1040 <puts@plt>
jmp    124d <main+0x9d>
xor    %ebx,%ebx
mov    0x8(%rbp),%r14
xor    %eax,%eax
call   10d0 <db_connect@plt>
test   %eax,%eax
je     122b <main+0x7b>
mov    0x2db8(%rip),%rcx
mov    (%rcx),%edi
lea    0xdf0(%rip),%rsi
jmp    1246 <main+0x96>
xor    %eax,%eax
call   1030 <db_begin@plt>
test   %eax,%eax
je     1266 <main+0xb6>
mov    0x2d9b(%rip),%rcx
mov    (%rcx),%edi
lea    0xdf9(%rip),%rsi
mov    %eax,%edx
call   1080 <fprintf@plt>
mov    $0x1,%ebx
mov    %ebx,%eax
add    $0x408,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2d7b(%rip),%rbp
mov    %rsp,%r15
lea    0xdf5(%rip),%r12
jmp    1296 <main+0xe6>
nopl   0x0(%rax)
xor    %ebx,%ebx
mov    %r14,%rdi
mov    %rbx,%rsi
call   1070 <learn_text@plt>
mov    $0x0,%ebx
test   %eax,%eax
jne    12f7 <main+0x147>
cmp    $0x2,%r13d
je     12a1 <main+0xf1>
test   %rbx,%rbx
je     12d5 <main+0x125>
test   %rbx,%rbx
jne    12ce <main+0x11e>
mov    0x0(%rbp),%edx
mov    %r15,%rdi
mov    $0x400,%esi
call   1060 <fgets@plt>
test   %rax,%rax
je     12d5 <main+0x125>
mov    %r15,%rdi
mov    %r12,%rsi
call   10b0 <strtok@plt>
mov    %rax,%rbx
test   %rax,%rax
je     1280 <main+0xd0>
cmpb   $0x0,(%rbx)
je     1280 <main+0xd0>
jmp    1282 <main+0xd2>
xor    %ebx,%ebx
xor    %eax,%eax
call   10a0 <db_commit@plt>
test   %eax,%eax
je     132c <main+0x17c>
mov    0x2cef(%rip),%rcx
mov    (%rcx),%edi
lea    0xdca(%rip),%rsi
jmp    1246 <main+0x96>
mov    0x2cda(%rip),%rbx
mov    (%rbx),%edi
lea    0xd68(%rip),%rsi
mov    %eax,%edx
call   1080 <fprintf@plt>
xor    %eax,%eax
call   10c0 <db_rollback@plt>
test   %eax,%eax
je     1327 <main+0x177>
mov    (%rbx),%edi
lea    0xd6a(%rip),%rsi
jmp    1246 <main+0x96>
mov    $0x1,%ebx
xor    %eax,%eax
call   1090 <db_disconnect@plt>
test   %eax,%eax
je     1252 <main+0xa2>
mov    0x2c96(%rip),%rcx
mov    (%rcx),%edi
lea    0xd9f(%rip),%rsi
jmp    1246 <main+0x96>

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

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 = [29 x i8] c"<Unable to learn text (%d)>\0A\00"
@.str.7 = [48 x i8] c"<Unable to rollback database transaction (%d)>\0A\00"
@.str.8 = [46 x i8] c"<Unable to commit database transaction (%d)>\0A\00"
@.str.9 = [43 x i8] c"<Unable to disconnect from database (%d)>\0A\00"
@str = [26 x i8] c"Brain access for learning\00"
@str.10 = [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 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%5 = and i32 %0, -2
%6 = icmp eq i32 %5, 2
br i1 %6, label %12, label %7
7: ; preds = %2
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str, i64 0, i64 0))
%9 = load i8*, i8** %1
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i8* %9)
%11 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([48 x i8], [48 x i8]* @str.10, i64 0, i64 0))
br label %77
12: ; preds = %2
%13 = getelementptr inbounds i8*, i8** %1, i64 1
%14 = load i8*, i8** %13
%15 = icmp eq i32 %0, 3
br i1 %15, label %16, label %19
16: ; preds = %12
%17 = getelementptr inbounds i8*, i8** %1, i64 2
%18 = load i8*, i8** %17
br label %19
19: ; preds = %12, %16
%20 = phi i8* [ %18, %16 ], [ null, %12 ]
%21 = tail call i32 (...) @db_connect()
%22 = icmp eq i32 %21, 0
br i1 %22, label %26, label %23
23: ; preds = %19
%24 = load i32, i32* @stderr
%25 = tail call i32 @fprintf(i32 %24, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.3, i64 0, i64 0), i32 %21)
br label %77
26: ; preds = %19
%27 = tail call i32 (...) @db_begin()
%28 = icmp eq i32 %27, 0
br i1 %28, label %29, label %31
29: ; preds = %26
%30 = icmp eq i32 %0, 2
br label %34
31: ; preds = %26
%32 = load i32, i32* @stderr
%33 = tail call i32 @fprintf(i32 %32, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.4, i64 0, i64 0), i32 %27)
br label %77
34: ; preds = %29, %52
%35 = phi i8* [ null, %52 ], [ %20, %29 ]
%36 = icmp ne i8* %35, null
%37 = select i1 %30, i1 true, i1 %36
br i1 %37, label %38, label %64
38: ; preds = %34
%39 = icmp eq i8* %35, null
br i1 %39, label %40, label %47
40: ; preds = %38
%41 = load i32, i32* @stdin
%42 = call i32* @fgets(i8* %4, i32 1024, i32 %41)
%43 = icmp eq i32* %42, null
br i1 %43, label %64, label %44
44: ; preds = %40
%45 = call i8* @strtok(i8* %4, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
%46 = icmp eq i8* %45, null
br i1 %46, label %52, label %47
47: ; preds = %38, %44
%48 = phi i8* [ %45, %44 ], [ %35, %38 ]
%49 = load i8, i8* %48
%50 = icmp eq i8 %49, 0
%51 = select i1 %50, i8* null, i8* %48
br label %52
52: ; preds = %47, %44
%53 = phi i8* [ %51, %47 ], [ null, %44 ]
%54 = call i32 @learn_text(i8* %14, i8* %53)
%55 = icmp eq i32 %54, 0
br i1 %55, label %34, label %56
56: ; preds = %52
%57 = load i32, i32* @stderr
%58 = call i32 @fprintf(i32 %57, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.6, i64 0, i64 0), i32 %54)
%59 = call i32 (...) @db_rollback()
%60 = icmp eq i32 %59, 0
br i1 %60, label %70, label %61
61: ; preds = %56
%62 = load i32, i32* @stderr
%63 = call i32 @fprintf(i32 %62, i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.7, i64 0, i64 0), i32 %59)
br label %77
64: ; preds = %40, %34
%65 = call i32 (...) @db_commit()
%66 = icmp eq i32 %65, 0
br i1 %66, label %70, label %67
67: ; preds = %64
%68 = load i32, i32* @stderr
%69 = call i32 @fprintf(i32 %68, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.8, i64 0, i64 0), i32 %65)
br label %77
70: ; preds = %64, %56
%71 = phi i32 [ 0, %64 ], [ 1, %56 ]
%72 = call i32 (...) @db_disconnect()
%73 = icmp eq i32 %72, 0
br i1 %73, label %77, label %74
74: ; preds = %70
%75 = load i32, i32* @stderr
%76 = call i32 @fprintf(i32 %75, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.9, i64 0, i64 0), i32 %72)
br label %77
77: ; preds = %70, %74, %67, %61, %31, %23, %7
%78 = phi i32 [ 1, %7 ], [ 1, %23 ], [ 1, %31 ], [ 1, %61 ], [ 1, %74 ], [ 1, %67 ], [ %71, %70 ]
ret i32 %78
}