#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 EXIT_FAILURE;
int EXIT_SUCCESS;
int /*<<< orphan*/ printf(char *, ...);
scalar_t__ unpack_cob(char *);
int main(int argc, char *argv[]) {
  if (argc != 2) {
    printf("usage: %s <filename.cob>\n", argv[0]);
    return EXIT_FAILURE;
  }
  if (unpack_cob(argv[1])) {
    printf("COB file processed successfully.\n");
  } else {
    printf("Error, couldn't process COB file: \"%s\".\n", argv[1]);
    return EXIT_FAILURE;
  }
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     1166 <main+0x46>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xeb2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0x2e84(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    11c3 <main+0xa3>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1040 <unpack_cob@plt>
cmp    $0x0,%rax
je     1190 <main+0x70>
lea    0xe96(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11b7 <main+0x97>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xe9d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0x2e33(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    11c3 <main+0xa3>
mov    0x2e1a(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
mov    %rsi,%rbx
cmp    $0x2,%edi
jne    115c <main+0x2c>
mov    0x8(%rbx),%rdi
call   1050 <unpack_cob@plt>
test   %rax,%rax
je     1168 <main+0x38>
lea    0xef5(%rip),%rdi
call   1030 <puts@plt>
mov    0x2e7e(%rip),%rax
jmp    1181 <main+0x51>
mov    (%rbx),%rsi
lea    0xe9a(%rip),%rdi
jmp    1173 <main+0x43>
mov    0x8(%rbx),%rsi
lea    0xea7(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x2e5f(%rip),%rax
mov    (%rax),%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [26 x i8] c"usage: %s <filename.cob>\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [34 x i8] c"COB file processed successfully.\0A\00"
@.str.2 = [41 x i8] c"Error, couldn't process COB file: \22%s\22.\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%6 = load i32, i32* %4
%7 = icmp ne i32 %6, 2
br i1 %7, label %8, label %14
8: ; preds = %2
%9 = load i8**, i8*** %5
%10 = getelementptr inbounds i8*, i8** %9, i64 0
%11 = load i8*, i8** %10
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i8* %11)
%13 = load i32, i32* @EXIT_FAILURE
store i32 %13, i32* %3
br label %30
14: ; preds = %2
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 1
%17 = load i8*, i8** %16
%18 = call i64 @unpack_cob(i8* %17)
%19 = icmp ne i64 %18, 0
br i1 %19, label %20, label %22
20: ; preds = %14
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0))
br label %28
22: ; preds = %14
%23 = load i8**, i8*** %5
%24 = getelementptr inbounds i8*, i8** %23, i64 1
%25 = load i8*, i8** %24
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.2, i64 0, i64 0), i8* %25)
%27 = load i32, i32* @EXIT_FAILURE
store i32 %27, i32* %3
br label %30
28: ; preds = %20
%29 = load i32, i32* @EXIT_SUCCESS
store i32 %29, i32* %3
br label %30
30: ; preds = %28, %22, %8
%31 = load i32, i32* %3
ret i32 %31
}

LLVM IR (-O2):
@.str = [26 x i8] c"usage: %s <filename.cob>\0A\00"
@EXIT_FAILURE = global i32 0
@.str.2 = [41 x i8] c"Error, couldn't process COB file: \22%s\22.\0A\00"
@EXIT_SUCCESS = global i32 0
@str = [33 x i8] c"COB file processed successfully.\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 2
br i1 %3, label %7, label %4
4: ; preds = %2
%5 = load i8*, i8** %1
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i8* %5)
br label %17
7: ; preds = %2
%8 = getelementptr inbounds i8*, i8** %1, i64 1
%9 = load i8*, i8** %8
%10 = tail call i64 @unpack_cob(i8* %9)
%11 = icmp eq i64 %10, 0
br i1 %11, label %14, label %12
12: ; preds = %7
%13 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @str, i64 0, i64 0))
br label %17
14: ; preds = %7
%15 = load i8*, i8** %8
%16 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @.str.2, i64 0, i64 0), i8* %15)
br label %17
17: ; preds = %12, %14, %4
%18 = phi i32* [ @EXIT_FAILURE, %4 ], [ @EXIT_SUCCESS, %12 ], [ @EXIT_FAILURE, %14 ]
%19 = load i32, i32* %18
ret i32 %19
}