#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 decode_hex();
int encode_hex();
int getopt(int, char **, char *);
int main(int argc, char **argv) {
  int ret, decode = 0;
  while ((ret = getopt(argc, argv, "d"))) {
    if (ret < 0)
      break;
    switch (ret) {
    case 'd':
      decode = 1;
      break;
    }
  }
  if (decode)
    return decode_hex();
  else
    return encode_hex();
}


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)
movl   $0x0,-0x18(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xea5(%rip),%rdx
call   1040 <getopt@plt>
mov    %eax,-0x14(%rbp)
cmp    $0x0,%eax
je     1198 <main+0x68>
cmpl   $0x0,-0x14(%rbp)
jge    117b <main+0x4b>
jmp    1198 <main+0x68>
mov    -0x14(%rbp),%eax
sub    $0x64,%eax
jne    1193 <main+0x63>
jmp    118c <main+0x5c>
movl   $0x1,-0x18(%rbp)
jmp    114d <main+0x1d>
cmpl   $0x0,-0x18(%rbp)
je     11b1 <main+0x81>
mov    $0x0,%al
call   1030 <decode_hex@plt>
mov    %eax,-0x4(%rbp)
jmp    11bb <main+0x8b>
mov    $0x0,%al
call   1050 <encode_hex@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rsi,%r15
mov    %edi,%ebp
lea    0xebc(%rip),%rdx
call   1040 <getopt@plt>
test   %eax,%eax
jle    118b <main+0x5b>
xor    %ebx,%ebx
mov    $0x1,%r12d
lea    0xea4(%rip),%r14
nopl   0x0(%rax)
cmp    $0x64,%eax
cmove  %r12d,%ebx
mov    %ebp,%edi
mov    %r15,%rsi
mov    %r14,%rdx
call   1040 <getopt@plt>
test   %eax,%eax
jg     1160 <main+0x30>
test   %ebx,%ebx
je     118b <main+0x5b>
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <decode_hex@plt>
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1050 <encode_hex@plt>

LLVM IR (-O0):
@.str = [2 x i8] c"d\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %7
br label %8
8: ; preds = %20, %2
%9 = load i32, i32* %4
%10 = load i8**, i8*** %5
%11 = call i32 @getopt(i32 %9, i8** %10, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32 %11, i32* %6
%12 = icmp ne i32 %11, 0
br i1 %12, label %13, label %21
13: ; preds = %8
%14 = load i32, i32* %6
%15 = icmp slt i32 %14, 0
br i1 %15, label %16, label %17
16: ; preds = %13
br label %21
17: ; preds = %13
%18 = load i32, i32* %6
switch i32 %18, label %20 [
i32 100, label %19
]
19: ; preds = %17
store i32 1, i32* %7
br label %20
20: ; preds = %17, %19
br label %8
21: ; preds = %16, %8
%22 = load i32, i32* %7
%23 = icmp ne i32 %22, 0
br i1 %23, label %24, label %26
24: ; preds = %21
%25 = call i32 (...) @decode_hex()
store i32 %25, i32* %3
br label %28
26: ; preds = %21
%27 = call i32 (...) @encode_hex()
store i32 %27, i32* %3
br label %28
28: ; preds = %26, %24
%29 = load i32, i32* %3
ret i32 %29
}

LLVM IR (-O2):
@.str = [2 x i8] c"d\00"
define i32 @main(i32 %0, i8** %1) {
%3 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%4 = icmp slt i32 %3, 1
br i1 %4, label %16, label %5
5: ; preds = %2, %5
%6 = phi i32 [ %10, %5 ], [ %3, %2 ]
%7 = phi i32 [ %9, %5 ], [ 0, %2 ]
%8 = icmp eq i32 %6, 100
%9 = select i1 %8, i32 1, i32 %7
%10 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%11 = icmp slt i32 %10, 1
br i1 %11, label %12, label %5
12: ; preds = %5
%13 = icmp eq i32 %9, 0
br i1 %13, label %16, label %14
14: ; preds = %12
%15 = tail call i32 (...) @decode_hex()
br label %18
16: ; preds = %2, %12
%17 = tail call i32 (...) @encode_hex()
br label %18
18: ; preds = %16, %14
%19 = phi i32 [ %15, %14 ], [ %17, %16 ]
ret i32 %19
}