#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 /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
unsigned long long imagoAllocSessionId();
int imagoLoadImageFromFile(char *);
int imagoRecognize(int *);
int /*<<< orphan*/ imagoReleaseSessionId(unsigned long long);
int imagoSaveMolToFile(char *);
int /*<<< orphan*/ imagoSetSessionId(unsigned long long);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stderr;
int main(int argc, char *argv[]) {
  int warnings;
  int ret;
  unsigned long long session;
  if (argc < 3) {
    fprintf(stderr, "Usage: <source image> <dest molfile>\n");
    return -1;
  }
  session = imagoAllocSessionId();
  imagoSetSessionId(session);
  printf("Loading image...");
  ret = imagoLoadImageFromFile(argv[1]);
  if (ret != 1) {
    fprintf(stderr, "Cannot load image\n");
    return -1;
  }
  printf("OK\n");
  printf("Recognizing image...");
  ret = imagoRecognize(&warnings);
  if (ret != 1) {
    fprintf(stderr, "Cannot recognize image\n");
    return -1;
  }
  printf("OK\n");
  printf("Number of warnings: %d\n", warnings);
  printf("Saving recongized molecule...");
  ret = imagoSaveMolToFile(argv[2]);
  if (ret != 1) {
    fprintf(stderr, "Cannot save molecule\n");
    return -1;
  }
  printf("OK\n");
  imagoReleaseSessionId(session);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x3,-0x8(%rbp)
jge    11c1 <main+0x41>
mov    0x2e39(%rip),%rax
mov    (%rax),%edi
lea    0xe50(%rip),%rsi
call   1080 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    12f7 <main+0x177>
mov    $0x0,%al
call   1060 <imagoAllocSessionId@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
call   10a0 <imagoSetSessionId@plt>
lea    0xe4a(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1040 <imagoLoadImageFromFile@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x1,-0x18(%rbp)
je     121e <main+0x9e>
mov    0x2ddc(%rip),%rax
mov    (%rax),%edi
lea    0xe2a(%rip),%rsi
call   1080 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    12f7 <main+0x177>
lea    0xe25(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    0xe1b(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    -0x14(%rbp),%rdi
call   1090 <imagoRecognize@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x1,-0x18(%rbp)
je     1271 <main+0xf1>
mov    0x2d89(%rip),%rax
mov    (%rax),%edi
lea    0xe03(%rip),%rsi
call   1080 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    12f7 <main+0x177>
lea    0xdd2(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x14(%rbp),%esi
lea    0xdf2(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    0xdfc(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1030 <imagoSaveMolToFile@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x1,-0x18(%rbp)
je     12d9 <main+0x159>
mov    0x2d21(%rip),%rax
mov    (%rax),%edi
lea    0xde9(%rip),%rsi
call   1080 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    12f7 <main+0x177>
lea    0xd6a(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x20(%rbp),%rdi
call   1050 <imagoReleaseSessionId@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
cmp    $0x2,%edi
jg     11b2 <main+0x22>
mov    0x2e3c(%rip),%rax
mov    (%rax),%edi
lea    0xe53(%rip),%rsi
jmp    1292 <main+0x102>
mov    %rsi,%rbx
xor    %eax,%eax
call   1060 <imagoAllocSessionId@plt>
mov    %rax,%r14
mov    %rax,%rdi
call   10b0 <imagoSetSessionId@plt>
lea    0xe58(%rip),%rdi
xor    %eax,%eax
call   1080 <printf@plt>
mov    0x8(%rbx),%rdi
call   1040 <imagoLoadImageFromFile@plt>
cmp    $0x1,%eax
jne    125e <main+0xce>
lea    0xed9(%rip),%rdi
call   1070 <puts@plt>
lea    0xe54(%rip),%rdi
xor    %eax,%eax
call   1080 <printf@plt>
lea    0xc(%rsp),%rdi
call   10a0 <imagoRecognize@plt>
cmp    $0x1,%eax
jne    1270 <main+0xe0>
lea    0xeb0(%rip),%rdi
call   1070 <puts@plt>
mov    0xc(%rsp),%esi
lea    0xe54(%rip),%rdi
xor    %ebp,%ebp
xor    %eax,%eax
call   1080 <printf@plt>
lea    0xe5c(%rip),%rdi
xor    %eax,%eax
call   1080 <printf@plt>
mov    0x10(%rbx),%rdi
call   1030 <imagoSaveMolToFile@plt>
cmp    $0x1,%eax
jne    1282 <main+0xf2>
lea    0xe74(%rip),%rdi
call   1070 <puts@plt>
mov    %r14,%rdi
call   1050 <imagoReleaseSessionId@plt>
jmp    129c <main+0x10c>
mov    0x2d7b(%rip),%rax
mov    (%rax),%edi
lea    0xdc9(%rip),%rsi
jmp    1292 <main+0x102>
mov    0x2d69(%rip),%rax
mov    (%rax),%edi
lea    0xddf(%rip),%rsi
jmp    1292 <main+0x102>
mov    0x2d57(%rip),%rax
mov    (%rax),%edi
lea    0xe1b(%rip),%rsi
call   1090 <fprintf@plt>
mov    $0xffffffff,%ebp
mov    %ebp,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [38 x i8] c"Usage: <source image> <dest molfile>\0A\00"
@.str.1 = [17 x i8] c"Loading image...\00"
@.str.2 = [19 x i8] c"Cannot load image\0A\00"
@.str.3 = [4 x i8] c"OK\0A\00"
@.str.4 = [21 x i8] c"Recognizing image...\00"
@.str.5 = [24 x i8] c"Cannot recognize image\0A\00"
@.str.6 = [24 x i8] c"Number of warnings: %d\0A\00"
@.str.7 = [30 x i8] c"Saving recongized molecule...\00"
@.str.8 = [22 x i8] c"Cannot save molecule\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = load i32, i32* %4
%10 = icmp slt i32 %9, 3
br i1 %10, label %11, label %14
11: ; preds = %2
%12 = load i32, i32* @stderr
%13 = call i32 @fprintf(i32 %12, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %3
br label %55
14: ; preds = %2
%15 = call i64 (...) @imagoAllocSessionId()
store i64 %15, i64* %8
%16 = load i64, i64* %8
%17 = call i32 @imagoSetSessionId(i64 %16)
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0))
%19 = load i8**, i8*** %5
%20 = getelementptr inbounds i8*, i8** %19, i64 1
%21 = load i8*, i8** %20
%22 = call i32 @imagoLoadImageFromFile(i8* %21)
store i32 %22, i32* %7
%23 = load i32, i32* %7
%24 = icmp ne i32 %23, 1
br i1 %24, label %25, label %28
25: ; preds = %14
%26 = load i32, i32* @stderr
%27 = call i32 @fprintf(i32 %26, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0))
store i32 -1, i32* %3
br label %55
28: ; preds = %14
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0))
%31 = call i32 @imagoRecognize(i32* %6)
store i32 %31, i32* %7
%32 = load i32, i32* %7
%33 = icmp ne i32 %32, 1
br i1 %33, label %34, label %37
34: ; preds = %28
%35 = load i32, i32* @stderr
%36 = call i32 @fprintf(i32 %35, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.5, i64 0, i64 0))
store i32 -1, i32* %3
br label %55
37: ; preds = %28
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%39 = load i32, i32* %6
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.6, i64 0, i64 0), i32 %39)
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.7, i64 0, i64 0))
%42 = load i8**, i8*** %5
%43 = getelementptr inbounds i8*, i8** %42, i64 2
%44 = load i8*, i8** %43
%45 = call i32 @imagoSaveMolToFile(i8* %44)
store i32 %45, i32* %7
%46 = load i32, i32* %7
%47 = icmp ne i32 %46, 1
br i1 %47, label %48, label %51
48: ; preds = %37
%49 = load i32, i32* @stderr
%50 = call i32 @fprintf(i32 %49, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.8, i64 0, i64 0))
store i32 -1, i32* %3
br label %55
51: ; preds = %37
%52 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%53 = load i64, i64* %8
%54 = call i32 @imagoReleaseSessionId(i64 %53)
store i32 0, i32* %3
br label %55
55: ; preds = %51, %48, %34, %25, %11
%56 = load i32, i32* %3
ret i32 %56
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [38 x i8] c"Usage: <source image> <dest molfile>\0A\00"
@.str.1 = [17 x i8] c"Loading image...\00"
@.str.2 = [19 x i8] c"Cannot load image\0A\00"
@.str.4 = [21 x i8] c"Recognizing image...\00"
@.str.5 = [24 x i8] c"Cannot recognize image\0A\00"
@.str.6 = [24 x i8] c"Number of warnings: %d\0A\00"
@.str.7 = [30 x i8] c"Saving recongized molecule...\00"
@.str.8 = [22 x i8] c"Cannot save molecule\0A\00"
@str.10 = [3 x i8] c"OK\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
%5 = icmp slt i32 %0, 3
br i1 %5, label %6, label %9
6: ; preds = %2
%7 = load i32, i32* @stderr
%8 = tail call i32 @fprintf(i32 %7, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0))
br label %43
9: ; preds = %2
%10 = tail call i64 (...) @imagoAllocSessionId()
%11 = tail call i32 @imagoSetSessionId(i64 %10)
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0))
%13 = getelementptr inbounds i8*, i8** %1, i64 1
%14 = load i8*, i8** %13
%15 = tail call i32 @imagoLoadImageFromFile(i8* %14)
%16 = icmp eq i32 %15, 1
br i1 %16, label %20, label %17
17: ; preds = %9
%18 = load i32, i32* @stderr
%19 = tail call i32 @fprintf(i32 %18, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0))
br label %43
20: ; preds = %9
%21 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @str.10, i64 0, i64 0))
%22 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0))
%23 = call i32 @imagoRecognize(i32* %3)
%24 = icmp eq i32 %23, 1
br i1 %24, label %28, label %25
25: ; preds = %20
%26 = load i32, i32* @stderr
%27 = call i32 @fprintf(i32 %26, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.5, i64 0, i64 0))
br label %43
28: ; preds = %20
%29 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @str.10, i64 0, i64 0))
%30 = load i32, i32* %3
%31 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.6, i64 0, i64 0), i32 %30)
%32 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.7, i64 0, i64 0))
%33 = getelementptr inbounds i8*, i8** %1, i64 2
%34 = load i8*, i8** %33
%35 = call i32 @imagoSaveMolToFile(i8* %34)
%36 = icmp eq i32 %35, 1
br i1 %36, label %40, label %37
37: ; preds = %28
%38 = load i32, i32* @stderr
%39 = call i32 @fprintf(i32 %38, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.8, i64 0, i64 0))
br label %43
40: ; preds = %28
%41 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @str.10, i64 0, i64 0))
%42 = call i32 @imagoReleaseSessionId(i64 %10)
br label %43
43: ; preds = %40, %37, %25, %17, %6
%44 = phi i32 [ -1, %6 ], [ -1, %17 ], [ -1, %25 ], [ -1, %37 ], [ 0, %40 ]
ret i32 %44
}