#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*/ bin2txt(char *, char *);
int /*<<< orphan*/ printf(char *, ...);
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ txt2bin(char *, char *);
int main(int argc, char **argv) {
  if (argc < 4) {
    printf("USAGE: convertvec method input_path output_path\n");
    printf("Method is either bin2txt or txt2bin\n");
    return 0;
  }
  if (strcmp(argv[1], "bin2txt") == 0)
    bin2txt(argv[2], argv[3]);
  else if (strcmp(argv[1], "txt2bin") == 0)
    txt2bin(argv[2], argv[3]);
  else
    printf("Unknown method: %s\n", argv[1]);
  return 0;
}


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   $0x4,-0x8(%rbp)
jge    1188 <main+0x48>
lea    0xe99(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xebc(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    121a <main+0xda>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xebf(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    11c0 <main+0x80>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rsi
call   1040 <bin2txt@plt>
jmp    1213 <main+0xd3>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe8f(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    11f8 <main+0xb8>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rsi
call   1060 <txt2bin@plt>
jmp    120e <main+0xce>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xe5f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1213 <main+0xd3>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
cmp    $0x3,%edi
jg     1170 <main+0x20>
lea    0xebf(%rip),%rdi
call   1030 <puts@plt>
lea    0xee3(%rip),%rdi
call   1030 <puts@plt>
jmp    11cd <main+0x7d>
mov    %rsi,%rbx
mov    0x8(%rsi),%rdi
lea    0xe82(%rip),%rsi
call   1060 <strcmp@plt>
test   %rax,%rax
je     11b1 <main+0x61>
mov    0x8(%rbx),%rdi
lea    0xed5(%rip),%rsi
call   1060 <strcmp@plt>
test   %rax,%rax
je     11c0 <main+0x70>
mov    0x8(%rbx),%rsi
lea    0xe60(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    11cd <main+0x7d>
mov    0x10(%rbx),%rdi
mov    0x18(%rbx),%rsi
call   1050 <bin2txt@plt>
jmp    11cd <main+0x7d>
mov    0x10(%rbx),%rdi
mov    0x18(%rbx),%rsi
call   1070 <txt2bin@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [49 x i8] c"USAGE: convertvec method input_path output_path\0A\00"
@.str.1 = [37 x i8] c"Method is either bin2txt or txt2bin\0A\00"
@.str.2 = [8 x i8] c"bin2txt\00"
@.str.3 = [8 x i8] c"txt2bin\00"
@.str.4 = [20 x i8] c"Unknown method: %s\0A\00"
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 slt i32 %6, 4
br i1 %7, label %8, label %11
8: ; preds = %2
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str, i64 0, i64 0))
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %3
br label %46
11: ; preds = %2
%12 = load i8**, i8*** %5
%13 = getelementptr inbounds i8*, i8** %12, i64 1
%14 = load i8*, i8** %13
%15 = call i64 @strcmp(i8* %14, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0))
%16 = icmp eq i64 %15, 0
br i1 %16, label %17, label %25
17: ; preds = %11
%18 = load i8**, i8*** %5
%19 = getelementptr inbounds i8*, i8** %18, i64 2
%20 = load i8*, i8** %19
%21 = load i8**, i8*** %5
%22 = getelementptr inbounds i8*, i8** %21, i64 3
%23 = load i8*, i8** %22
%24 = call i32 @bin2txt(i8* %20, i8* %23)
br label %45
25: ; preds = %11
%26 = load i8**, i8*** %5
%27 = getelementptr inbounds i8*, i8** %26, i64 1
%28 = load i8*, i8** %27
%29 = call i64 @strcmp(i8* %28, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
%30 = icmp eq i64 %29, 0
br i1 %30, label %31, label %39
31: ; preds = %25
%32 = load i8**, i8*** %5
%33 = getelementptr inbounds i8*, i8** %32, i64 2
%34 = load i8*, i8** %33
%35 = load i8**, i8*** %5
%36 = getelementptr inbounds i8*, i8** %35, i64 3
%37 = load i8*, i8** %36
%38 = call i32 @txt2bin(i8* %34, i8* %37)
br label %44
39: ; preds = %25
%40 = load i8**, i8*** %5
%41 = getelementptr inbounds i8*, i8** %40, i64 1
%42 = load i8*, i8** %41
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0), i8* %42)
br label %44
44: ; preds = %39, %31
br label %45
45: ; preds = %44, %17
store i32 0, i32* %3
br label %46
46: ; preds = %45, %8
%47 = load i32, i32* %3
ret i32 %47
}

LLVM IR (-O2):
@.str.2 = [8 x i8] c"bin2txt\00"
@.str.3 = [8 x i8] c"txt2bin\00"
@.str.4 = [20 x i8] c"Unknown method: %s\0A\00"
@str = [48 x i8] c"USAGE: convertvec method input_path output_path\00"
@str.5 = [36 x i8] c"Method is either bin2txt or txt2bin\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp slt i32 %0, 4
br i1 %3, label %4, label %7
4: ; preds = %2
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([48 x i8], [48 x i8]* @str, i64 0, i64 0))
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @str.5, i64 0, i64 0))
br label %31
7: ; preds = %2
%8 = getelementptr inbounds i8*, i8** %1, i64 1
%9 = load i8*, i8** %8
%10 = tail call i64 @strcmp(i8* %9, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0))
%11 = icmp eq i64 %10, 0
br i1 %11, label %12, label %18
12: ; preds = %7
%13 = getelementptr inbounds i8*, i8** %1, i64 2
%14 = load i8*, i8** %13
%15 = getelementptr inbounds i8*, i8** %1, i64 3
%16 = load i8*, i8** %15
%17 = tail call i32 @bin2txt(i8* %14, i8* %16)
br label %31
18: ; preds = %7
%19 = load i8*, i8** %8
%20 = tail call i64 @strcmp(i8* %19, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
%21 = icmp eq i64 %20, 0
br i1 %21, label %22, label %28
22: ; preds = %18
%23 = getelementptr inbounds i8*, i8** %1, i64 2
%24 = load i8*, i8** %23
%25 = getelementptr inbounds i8*, i8** %1, i64 3
%26 = load i8*, i8** %25
%27 = tail call i32 @txt2bin(i8* %24, i8* %26)
br label %31
28: ; preds = %18
%29 = load i8*, i8** %8
%30 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0), i8* %29)
br label %31
31: ; preds = %12, %28, %22, %4
ret i32 0
}