#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 /*<<< orphan*/ int32_t;

/* Variables and functions */
int EXIT_FAILURE;
int EXIT_SUCCESS;
int /*<<< orphan*/ base24_printPair(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
char *getCustom(int, char **, int);
int getCustomCount(int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdout;
int /*<<< orphan*/ stringToLong(char const *, long *);
int sub_to24pair(int argc, char *argv[]) {
  const char *arg_decimal = NULL;
  long argi = 0;
  int result = EXIT_SUCCESS;
  if (getCustomCount(argc) != 2) {
    fprintf(stderr, "to24pair expects exactly one additional argument!\n");
    result = EXIT_FAILURE;
  }
  if (result != EXIT_FAILURE) {
    arg_decimal = getCustom(argc, argv, 1);
  }
  if (result != EXIT_FAILURE) {
    if (!stringToLong(arg_decimal, &argi)) {
      fprintf(stderr, "Could not parse argument as decimal integer!\n");
      result = EXIT_FAILURE;
    }
  }
  if (result != EXIT_FAILURE) {
    if ((argi < (-96)) || (argi > (479))) {
      fprintf(stderr, "Argument must be in range -96 to 479!\n");
      result = EXIT_FAILURE;
    }
  }
  if (result != EXIT_FAILURE) {
    printf("Decimal value:  %ld\n", argi);
    printf("Base-24 pair:   ");
    base24_printPair(stdout, (int32_t)argi);
    printf("\n");
  }
  return result;
}


x86 assembly (clang, -O0):
<sub_to24pair>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
mov    0x2e42(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x24(%rbp)
mov    -0x4(%rbp),%edi
call   1040 <getCustomCount@plt>
cmp    $0x2,%eax
je     11bd <sub_to24pair+0x5d>
mov    0x2e3d(%rip),%rax
mov    (%rax),%edi
lea    0xe54(%rip),%rsi
call   1070 <fprintf@plt>
mov    0x2e20(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%eax
mov    0x2e11(%rip),%rcx
cmp    (%rcx),%eax
je     11e4 <sub_to24pair+0x84>
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    $0x1,%edx
call   1060 <getCustom@plt>
mov    %rax,-0x18(%rbp)
mov    -0x24(%rbp),%eax
mov    0x2dea(%rip),%rcx
cmp    (%rcx),%eax
je     1232 <sub_to24pair+0xd2>
mov    -0x18(%rbp),%rdi
lea    -0x20(%rbp),%rsi
call   1030 <stringToLong@plt>
cmp    $0x0,%eax
jne    122d <sub_to24pair+0xcd>
mov    0x2dcd(%rip),%rax
mov    (%rax),%edi
lea    0xe17(%rip),%rsi
call   1070 <fprintf@plt>
mov    0x2db0(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x24(%rbp)
jmp    1232 <sub_to24pair+0xd2>
mov    -0x24(%rbp),%eax
mov    0x2d9c(%rip),%rcx
cmp    (%rcx),%eax
je     1283 <sub_to24pair+0x123>
cmpq   $0xffffffffffffffa0,-0x20(%rbp)
jl     125d <sub_to24pair+0xfd>
cmpq   $0x1df,-0x20(%rbp)
jle    127e <sub_to24pair+0x11e>
mov    0x2d7c(%rip),%rax
mov    (%rax),%edi
lea    0xdf4(%rip),%rsi
call   1070 <fprintf@plt>
mov    0x2d5f(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x24(%rbp)
jmp    1283 <sub_to24pair+0x123>
mov    -0x24(%rbp),%eax
mov    0x2d4b(%rip),%rcx
cmp    (%rcx),%eax
je     12d7 <sub_to24pair+0x177>
mov    -0x20(%rbp),%rsi
lea    0xde8(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xdef(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    0x2d14(%rip),%rax
mov    (%rax),%edi
mov    -0x20(%rbp),%rax
mov    %eax,%esi
call   1080 <base24_printPair@plt>
lea    0xdb6(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x24(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sub_to24pair>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %edi,%ebp
movq   $0x0,(%rsp)
mov    0x2e3d(%rip),%rax
mov    (%rax),%ebx
call   1050 <getCustomCount@plt>
cmp    $0x2,%eax
jne    11b0 <sub_to24pair+0x40>
mov    0x2e3a(%rip),%r15
mov    (%r15),%ecx
cmp    %ecx,%ebx
jne    11d0 <sub_to24pair+0x60>
xor    %eax,%eax
cmp    %ecx,%ebx
jne    11e6 <sub_to24pair+0x76>
jmp    123e <sub_to24pair+0xce>
mov    0x2e29(%rip),%rax
mov    (%rax),%edi
lea    0xe40(%rip),%rsi
call   1080 <fprintf@plt>
mov    0x2e0c(%rip),%rax
mov    (%rax),%ebx
jmp    123e <sub_to24pair+0xce>
mov    %ebp,%edi
mov    %r14,%rsi
mov    $0x1,%edx
call   1070 <getCustom@plt>
mov    (%r15),%ecx
cmp    %ecx,%ebx
je     123e <sub_to24pair+0xce>
mov    %rsp,%rsi
mov    %rax,%rdi
call   1040 <stringToLong@plt>
test   %eax,%eax
je     1200 <sub_to24pair+0x90>
mov    (%r15),%eax
cmp    %eax,%ebx
jne    1212 <sub_to24pair+0xa2>
mov    %eax,%ebx
jmp    123e <sub_to24pair+0xce>
mov    0x2dd9(%rip),%rax
mov    (%rax),%edi
lea    0xe23(%rip),%rsi
jmp    1236 <sub_to24pair+0xc6>
mov    $0xfffffffffffffe20,%rcx
add    (%rsp),%rcx
cmp    $0xfffffffffffffdbf,%rcx
ja     124b <sub_to24pair+0xdb>
mov    0x2db3(%rip),%rax
mov    (%rax),%edi
lea    0xe2b(%rip),%rsi
call   1080 <fprintf@plt>
mov    (%r15),%ebx
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
cmp    %eax,%ebx
je     123e <sub_to24pair+0xce>
mov    (%rsp),%rsi
lea    0xe2e(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xe35(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x2d5a(%rip),%rax
mov    (%rax),%edi
mov    (%rsp),%esi
call   1090 <base24_printPair@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
jmp    123e <sub_to24pair+0xce>

LLVM IR (-O0):
@EXIT_SUCCESS = global i32 0
@stderr = global i32 0
@.str = [51 x i8] c"to24pair expects exactly one additional argument!\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [46 x i8] c"Could not parse argument as decimal integer!\0A\00"
@.str.2 = [39 x i8] c"Argument must be in range -96 to 479!\0A\00"
@.str.3 = [21 x i8] c"Decimal value: %ld\0A\00"
@.str.4 = [17 x i8] c"Base-24 pair: \00"
@stdout = global i32 0
@.str.5 = [2 x i8] c"\0A\00"
define i32 @sub_to24pair(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8**
%5 = alloca i8*
%6 = alloca i64
%7 = alloca i32
store i32 %0, i32* %3
store i8** %1, i8*** %4
store i8* null, i8** %5
store i64 0, i64* %6
%8 = load i32, i32* @EXIT_SUCCESS
store i32 %8, i32* %7
%9 = load i32, i32* %3
%10 = call i32 @getCustomCount(i32 %9)
%11 = icmp ne i32 %10, 2
br i1 %11, label %12, label %16
12: ; preds = %2
%13 = load i32, i32* @stderr
%14 = call i32 @fprintf(i32 %13, i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str, i64 0, i64 0))
%15 = load i32, i32* @EXIT_FAILURE
store i32 %15, i32* %7
br label %16
16: ; preds = %12, %2
%17 = load i32, i32* %7
%18 = load i32, i32* @EXIT_FAILURE
%19 = icmp ne i32 %17, %18
br i1 %19, label %20, label %24
20: ; preds = %16
%21 = load i32, i32* %3
%22 = load i8**, i8*** %4
%23 = call i8* @getCustom(i32 %21, i8** %22, i32 1)
store i8* %23, i8** %5
br label %24
24: ; preds = %20, %16
%25 = load i32, i32* %7
%26 = load i32, i32* @EXIT_FAILURE
%27 = icmp ne i32 %25, %26
br i1 %27, label %28, label %37
28: ; preds = %24
%29 = load i8*, i8** %5
%30 = call i32 @stringToLong(i8* %29, i64* %6)
%31 = icmp ne i32 %30, 0
br i1 %31, label %36, label %32
32: ; preds = %28
%33 = load i32, i32* @stderr
%34 = call i32 @fprintf(i32 %33, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.1, i64 0, i64 0))
%35 = load i32, i32* @EXIT_FAILURE
store i32 %35, i32* %7
br label %36
36: ; preds = %32, %28
br label %37
37: ; preds = %36, %24
%38 = load i32, i32* %7
%39 = load i32, i32* @EXIT_FAILURE
%40 = icmp ne i32 %38, %39
br i1 %40, label %41, label %52
41: ; preds = %37
%42 = load i64, i64* %6
%43 = icmp slt i64 %42, -96
br i1 %43, label %47, label %44
44: ; preds = %41
%45 = load i64, i64* %6
%46 = icmp sgt i64 %45, 479
br i1 %46, label %47, label %51
47: ; preds = %44, %41
%48 = load i32, i32* @stderr
%49 = call i32 @fprintf(i32 %48, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.2, i64 0, i64 0))
%50 = load i32, i32* @EXIT_FAILURE
store i32 %50, i32* %7
br label %51
51: ; preds = %47, %44
br label %52
52: ; preds = %51, %37
%53 = load i32, i32* %7
%54 = load i32, i32* @EXIT_FAILURE
%55 = icmp ne i32 %53, %54
br i1 %55, label %56, label %65
56: ; preds = %52
%57 = load i64, i64* %6
%58 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0), i64 %57)
%59 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0))
%60 = load i32, i32* @stdout
%61 = load i64, i64* %6
%62 = trunc i64 %61 to i32
%63 = call i32 @base24_printPair(i32 %60, i32 %62)
%64 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
br label %65
65: ; preds = %56, %52
%66 = load i32, i32* %7
ret i32 %66
}

LLVM IR (-O2):
@EXIT_SUCCESS = global i32 0
@stderr = global i32 0
@.str = [51 x i8] c"to24pair expects exactly one additional argument!\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [46 x i8] c"Could not parse argument as decimal integer!\0A\00"
@.str.2 = [39 x i8] c"Argument must be in range -96 to 479!\0A\00"
@.str.3 = [21 x i8] c"Decimal value: %ld\0A\00"
@.str.4 = [17 x i8] c"Base-24 pair: \00"
@stdout = global i32 0
define i32 @sub_to24pair(i32 %0, i8** %1) {
%3 = alloca i64
%4 = bitcast i64* %3 to i8*
store i64 0, i64* %3
%5 = load i32, i32* @EXIT_SUCCESS
%6 = tail call i32 @getCustomCount(i32 %0)
%7 = icmp eq i32 %6, 2
br i1 %7, label %12, label %8
8: ; preds = %2
%9 = load i32, i32* @stderr
%10 = tail call i32 @fprintf(i32 %9, i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str, i64 0, i64 0))
%11 = load i32, i32* @EXIT_FAILURE
br label %51
12: ; preds = %2
%13 = load i32, i32* @EXIT_FAILURE
%14 = icmp eq i32 %5, %13
br i1 %14, label %18, label %15
15: ; preds = %12
%16 = tail call i8* @getCustom(i32 %0, i8** %1, i32 1)
%17 = load i32, i32* @EXIT_FAILURE
br label %18
18: ; preds = %15, %12
%19 = phi i32 [ %17, %15 ], [ %13, %12 ]
%20 = phi i8* [ %16, %15 ], [ null, %12 ]
%21 = icmp eq i32 %5, %19
br i1 %21, label %51, label %22
22: ; preds = %18
%23 = call i32 @stringToLong(i8* %20, i64* %3)
%24 = icmp eq i32 %23, 0
br i1 %24, label %25, label %29
25: ; preds = %22
%26 = load i32, i32* @stderr
%27 = call i32 @fprintf(i32 %26, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.1, i64 0, i64 0))
%28 = load i32, i32* @EXIT_FAILURE
br label %51
29: ; preds = %22
%30 = load i32, i32* @EXIT_FAILURE
%31 = icmp eq i32 %5, %30
br i1 %31, label %51, label %32
32: ; preds = %29
%33 = load i64, i64* %3
%34 = add i64 %33, -480
%35 = icmp ult i64 %34, -576
br i1 %35, label %36, label %40
36: ; preds = %32
%37 = load i32, i32* @stderr
%38 = call i32 @fprintf(i32 %37, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.2, i64 0, i64 0))
%39 = load i32, i32* @EXIT_FAILURE
br label %51
40: ; preds = %32
%41 = icmp eq i32 %5, %30
br i1 %41, label %51, label %42
42: ; preds = %40
%43 = load i64, i64* %3
%44 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0), i64 %43)
%45 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0))
%46 = load i32, i32* @stdout
%47 = load i64, i64* %3
%48 = trunc i64 %47 to i32
%49 = call i32 @base24_printPair(i32 %46, i32 %48)
%50 = call i32 @putchar(i32 10)
br label %51
51: ; preds = %8, %18, %25, %29, %36, %42, %40
%52 = phi i32 [ %5, %42 ], [ %5, %40 ], [ %30, %29 ], [ %39, %36 ], [ %11, %8 ], [ %5, %18 ], [ %28, %25 ]
ret i32 %52
}