#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 */
typedef int uint32_t;

/* Variables and functions */
int O_CLOEXEC;
int O_RDONLY;
char *decideFat(int, int);
int /*<<< orphan*/ junction(char const *, int, char **);
int open(char *, int);
int read(int, int *, int);
int registerDeregister(char *, int);
int /*<<< orphan*/ strcmp(char *, char *);
int main(int argc, char **argv) {
  uint32_t signature;
  int fd;
  const char *target = "64";
  bool reg;
  if (argc == 2 && (reg = !strcmp(argv[1], "--register") ||
                          !strcmp(argv[1], "--deregister")))
    return registerDeregister(argv[0], reg);
  fd = open(argv[1], O_RDONLY | O_CLOEXEC);
  if (fd < 0)
    junction(target, argc, argv);
  if (read(fd, &signature, 4) != 4)
    junction(target, argc, argv);
  if (signature == 0xfeedface || signature == 0xcefaedfe)
    target = "32";
  else if (signature == 0xcafebabe || signature == 0xbebafeca)
    target = decideFat(fd, signature == 0xbebafeca);
  junction(target, argc, argv);
  return 1;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xe83(%rip),%rax
mov    %rax,-0x20(%rbp)
cmpl   $0x2,-0x8(%rbp)
jne    1200 <main+0xa0>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe69(%rip),%rsi
call   1050 <strcmp@plt>
mov    %eax,%ecx
mov    $0x1,%al
cmp    $0x0,%ecx
mov    %al,-0x25(%rbp)
je     11ce <main+0x6e>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe50(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
mov    %al,-0x25(%rbp)
mov    -0x25(%rbp),%al
mov    %al,%cl
and    $0x1,%cl
movzbl %cl,%ecx
mov    %ecx,-0x24(%rbp)
test   $0x1,%al
jne    11e9 <main+0x89>
jmp    1200 <main+0xa0>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
mov    -0x24(%rbp),%esi
call   1030 <registerDeregister@plt>
mov    %eax,-0x4(%rbp)
jmp    12e1 <main+0x181>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    0x2dd9(%rip),%rax
mov    (%rax),%esi
mov    0x2db8(%rip),%rax
or     (%rax),%esi
call   1080 <open@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jge    123c <main+0xdc>
mov    -0x20(%rbp),%rdi
mov    -0x8(%rbp),%esi
mov    -0x10(%rbp),%rdx
call   1060 <junction@plt>
mov    -0x18(%rbp),%edi
lea    -0x14(%rbp),%rsi
mov    $0x4,%edx
call   1040 <read@plt>
cmp    $0x4,%eax
je     1266 <main+0x106>
mov    -0x20(%rbp),%rdi
mov    -0x8(%rbp),%esi
mov    -0x10(%rbp),%rdx
call   1060 <junction@plt>
cmpl   $0xfeedface,-0x14(%rbp)
je     1280 <main+0x120>
cmpl   $0xcefaedfe,-0x14(%rbp)
jne    1290 <main+0x130>
lea    0xd94(%rip),%rax
mov    %rax,-0x20(%rbp)
jmp    12ca <main+0x16a>
cmpl   $0xcafebabe,-0x14(%rbp)
je     12aa <main+0x14a>
cmpl   $0xbebafeca,-0x14(%rbp)
jne    12c5 <main+0x165>
mov    -0x18(%rbp),%edi
cmpl   $0xbebafeca,-0x14(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%esi
call   1070 <decideFat@plt>
mov    %rax,-0x20(%rbp)
jmp    12ca <main+0x16a>
mov    -0x20(%rbp),%rdi
mov    -0x8(%rbp),%esi
mov    -0x10(%rbp),%rdx
call   1060 <junction@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%rbx
mov    %edi,%r14d
mov    0x8(%rsi),%rbp
cmp    $0x2,%edi
jne    11a5 <main+0x45>
lea    0xe85(%rip),%rsi
mov    %rbp,%rdi
call   1050 <strcmp@plt>
test   %eax,%eax
je     1264 <main+0x104>
lea    0xe79(%rip),%rsi
mov    %rbp,%rdi
call   1050 <strcmp@plt>
test   %eax,%eax
je     1264 <main+0x104>
mov    0x2e3c(%rip),%rax
mov    0x2e1d(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
mov    %rbp,%rdi
call   1080 <open@plt>
mov    %eax,%ebp
test   %eax,%eax
jns    11d7 <main+0x77>
lea    0xe34(%rip),%rdi
mov    %r14d,%esi
mov    %rbx,%rdx
call   1060 <junction@plt>
lea    0xc(%rsp),%rsi
mov    %ebp,%edi
mov    $0x4,%edx
call   1040 <read@plt>
cmp    $0x4,%eax
je     11ff <main+0x9f>
lea    0xe0c(%rip),%rdi
mov    %r14d,%esi
mov    %rbx,%rdx
call   1060 <junction@plt>
mov    0xc(%rsp),%eax
cmp    $0xcefaedfd,%eax
jg     122f <main+0xcf>
cmp    $0xbebafeca,%eax
je     1218 <main+0xb8>
cmp    $0xcafebabe,%eax
jne    1244 <main+0xe4>
xor    %esi,%esi
cmp    $0xbebafeca,%eax
sete   %sil
mov    %ebp,%edi
call   1070 <decideFat@plt>
mov    %rax,%rdi
jmp    124b <main+0xeb>
lea    0xde5(%rip),%rdi
cmp    $0xcefaedfe,%eax
je     124b <main+0xeb>
cmp    $0xfeedface,%eax
je     124b <main+0xeb>
lea    0xdb5(%rip),%rdi
mov    %r14d,%esi
mov    %rbx,%rdx
call   1060 <junction@plt>
mov    $0x1,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret
mov    (%rbx),%rdi
mov    $0x1,%esi
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
jmp    1030 <registerDeregister@plt>

LLVM IR (-O0):
@.str = [3 x i8] c"64\00"
@.str.1 = [11 x i8] c"--register\00"
@.str.2 = [13 x i8] c"--deregister\00"
@O_RDONLY = global i32 0
@O_CLOEXEC = global i32 0
@.str.3 = [3 x i8] c"32\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 i8*
%9 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8** %8
%10 = load i32, i32* %4
%11 = icmp eq i32 %10, 2
br i1 %11, label %12, label %34
12: ; preds = %2
%13 = load i8**, i8*** %5
%14 = getelementptr inbounds i8*, i8** %13, i64 1
%15 = load i8*, i8** %14
%16 = call i32 @strcmp(i8* %15, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
%17 = icmp ne i32 %16, 0
br i1 %17, label %18, label %25
18: ; preds = %12
%19 = load i8**, i8*** %5
%20 = getelementptr inbounds i8*, i8** %19, i64 1
%21 = load i8*, i8** %20
%22 = call i32 @strcmp(i8* %21, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
%23 = icmp ne i32 %22, 0
%24 = xor i1 %23, true
br label %25
25: ; preds = %18, %12
%26 = phi i1 [ true, %12 ], [ %24, %18 ]
%27 = zext i1 %26 to i32
store i32 %27, i32* %9
br i1 %26, label %28, label %34
28: ; preds = %25
%29 = load i8**, i8*** %5
%30 = getelementptr inbounds i8*, i8** %29, i64 0
%31 = load i8*, i8** %30
%32 = load i32, i32* %9
%33 = call i32 @registerDeregister(i8* %31, i32 %32)
store i32 %33, i32* %3
br label %83
34: ; preds = %25, %2
%35 = load i8**, i8*** %5
%36 = getelementptr inbounds i8*, i8** %35, i64 1
%37 = load i8*, i8** %36
%38 = load i32, i32* @O_RDONLY
%39 = load i32, i32* @O_CLOEXEC
%40 = or i32 %38, %39
%41 = call i32 @open(i8* %37, i32 %40)
store i32 %41, i32* %7
%42 = load i32, i32* %7
%43 = icmp slt i32 %42, 0
br i1 %43, label %44, label %49
44: ; preds = %34
%45 = load i8*, i8** %8
%46 = load i32, i32* %4
%47 = load i8**, i8*** %5
%48 = call i32 @junction(i8* %45, i32 %46, i8** %47)
br label %49
49: ; preds = %44, %34
%50 = load i32, i32* %7
%51 = call i32 @read(i32 %50, i32* %6, i32 4)
%52 = icmp ne i32 %51, 4
br i1 %52, label %53, label %58
53: ; preds = %49
%54 = load i8*, i8** %8
%55 = load i32, i32* %4
%56 = load i8**, i8*** %5
%57 = call i32 @junction(i8* %54, i32 %55, i8** %56)
br label %58
58: ; preds = %53, %49
%59 = load i32, i32* %6
%60 = icmp eq i32 %59, -17958194
br i1 %60, label %64, label %61
61: ; preds = %58
%62 = load i32, i32* %6
%63 = icmp eq i32 %62, -822415874
br i1 %63, label %64, label %65
64: ; preds = %61, %58
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8** %8
br label %78
65: ; preds = %61
%66 = load i32, i32* %6
%67 = icmp eq i32 %66, -889275714
br i1 %67, label %71, label %68
68: ; preds = %65
%69 = load i32, i32* %6
%70 = icmp eq i32 %69, -1095041334
br i1 %70, label %71, label %77
71: ; preds = %68, %65
%72 = load i32, i32* %7
%73 = load i32, i32* %6
%74 = icmp eq i32 %73, -1095041334
%75 = zext i1 %74 to i32
%76 = call i8* @decideFat(i32 %72, i32 %75)
store i8* %76, i8** %8
br label %77
77: ; preds = %71, %68
br label %78
78: ; preds = %77, %64
%79 = load i8*, i8** %8
%80 = load i32, i32* %4
%81 = load i8**, i8*** %5
%82 = call i32 @junction(i8* %79, i32 %80, i8** %81)
store i32 1, i32* %3
br label %83
83: ; preds = %78, %28
%84 = load i32, i32* %3
ret i32 %84
}

LLVM IR (-O2):
@.str = [3 x i8] c"64\00"
@.str.1 = [11 x i8] c"--register\00"
@.str.2 = [13 x i8] c"--deregister\00"
@O_RDONLY = global i32 0
@O_CLOEXEC = global i32 0
@.str.3 = [3 x i8] c"32\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
%5 = icmp eq i32 %0, 2
%6 = getelementptr inbounds i8*, i8** %1, i64 1
%7 = load i8*, i8** %6
br i1 %5, label %8, label %17
8: ; preds = %2
%9 = tail call i32 @strcmp(i8* dereferenceable(1) %7, i8* dereferenceable(11) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
%10 = icmp eq i32 %9, 0
br i1 %10, label %14, label %11
11: ; preds = %8
%12 = tail call i32 @strcmp(i8* dereferenceable(1) %7, i8* dereferenceable(13) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
%13 = icmp eq i32 %12, 0
br i1 %13, label %14, label %17
14: ; preds = %8, %11
%15 = load i8*, i8** %1
%16 = tail call i32 @registerDeregister(i8* %15, i32 1)
br label %40
17: ; preds = %2, %11
%18 = load i32, i32* @O_RDONLY
%19 = load i32, i32* @O_CLOEXEC
%20 = or i32 %19, %18
%21 = tail call i32 @open(i8* %7, i32 %20)
%22 = icmp slt i32 %21, 0
br i1 %22, label %23, label %25
23: ; preds = %17
%24 = tail call i32 @junction(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %0, i8** %1)
br label %25
25: ; preds = %23, %17
%26 = call i32 @read(i32 %21, i32* %3, i32 4)
%27 = icmp eq i32 %26, 4
br i1 %27, label %30, label %28
28: ; preds = %25
%29 = tail call i32 @junction(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %0, i8** %1)
br label %30
30: ; preds = %28, %25
%31 = load i32, i32* %3
switch i32 %31, label %36 [
i32 -17958194, label %37
i32 -822415874, label %37
i32 -889275714, label %32
i32 -1095041334, label %32
]
32: ; preds = %30, %30
%33 = icmp eq i32 %31, -1095041334
%34 = zext i1 %33 to i32
%35 = tail call i8* @decideFat(i32 %21, i32 %34)
br label %37
36: ; preds = %30
br label %37
37: ; preds = %30, %30, %36, %32
%38 = phi i8* [ %35, %32 ], [ getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), %30 ], [ getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), %30 ], [ getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), %36 ]
%39 = tail call i32 @junction(i8* %38, i32 %0, i8** %1)
br label %40
40: ; preds = %37, %14
%41 = phi i32 [ %16, %14 ], [ 1, %37 ]
ret i32 %41
}