#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;
scalar_t__ base24_digitToInt(char);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
char *getCustom(int, char **, int);
int getCustomCount(int);
int /*<<< orphan*/ isspace(char const);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ stderr;
int sub_from24digit(int argc, char *argv[]) {
  const char *arg_digit = NULL;
  const char *pc = NULL;
  char digit = 0;
  int val = 0;
  int result = EXIT_SUCCESS;
  if (getCustomCount(argc) != 2) {
    fprintf(stderr, "from24digit expects exactly one additional argument!\n");
    result = EXIT_FAILURE;
  }
  if (result != EXIT_FAILURE) {
    arg_digit = getCustom(argc, argv, 1);
  }
  if (result != EXIT_FAILURE) {
    pc = arg_digit;
    while (*pc != 0) {
      if (!isspace(*pc)) {
        if (digit != 0) {
          fprintf(stderr, "Provide no more than one base-24 digit!\n");
          result = EXIT_FAILURE;
          break;
        }
        digit = *pc;
      }
      pc++;
    }
    if (result != EXIT_FAILURE) {
      if (digit == 0) {
        fprintf(stderr, "Provide a base-24 digit!\n");
        result = EXIT_FAILURE;
      }
    }
  }
  if (result != EXIT_FAILURE) {
    val = (int)base24_digitToInt(digit);
    if (val == -1) {
      fprintf(stderr, "Could not parse as base-24 digit!\n");
      result = EXIT_FAILURE;
    }
  }
  if (result != EXIT_FAILURE) {
    printf("Base-24 digit:  %c\n", digit);
    printf("Decimal value:  %d\n", val);
  }
  return result;
}


x86 assembly (clang, -O0):
<sub_from24digit>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
movb   $0x0,-0x21(%rbp)
movl   $0x0,-0x28(%rbp)
mov    0x2e3f(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x4(%rbp),%edi
call   1040 <getCustomCount@plt>
cmp    $0x2,%eax
je     11c8 <sub_from24digit+0x68>
mov    0x2e32(%rip),%rax
mov    (%rax),%edi
lea    0xe49(%rip),%rsi
call   1080 <fprintf@plt>
mov    0x2e15(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
mov    0x2e06(%rip),%rcx
cmp    (%rcx),%eax
je     11ef <sub_from24digit+0x8f>
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    $0x1,%edx
call   1060 <getCustom@plt>
mov    %rax,-0x18(%rbp)
mov    -0x2c(%rbp),%eax
mov    0x2ddf(%rip),%rcx
cmp    (%rcx),%eax
je     12c5 <sub_from24digit+0x165>
mov    -0x18(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     127b <sub_from24digit+0x11b>
mov    -0x20(%rbp),%rax
movsbl (%rax),%edi
call   1070 <isspace@plt>
cmp    $0x0,%eax
jne    126a <sub_from24digit+0x10a>
movsbl -0x21(%rbp),%eax
cmp    $0x0,%eax
je     1261 <sub_from24digit+0x101>
mov    0x2d9e(%rip),%rax
mov    (%rax),%edi
lea    0xdeb(%rip),%rsi
call   1080 <fprintf@plt>
mov    0x2d81(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x2c(%rbp)
jmp    127b <sub_from24digit+0x11b>
mov    -0x20(%rbp),%rax
mov    (%rax),%al
mov    %al,-0x21(%rbp)
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    1209 <sub_from24digit+0xa9>
mov    -0x2c(%rbp),%eax
mov    0x2d53(%rip),%rcx
cmp    (%rcx),%eax
je     12c0 <sub_from24digit+0x160>
movsbl -0x21(%rbp),%eax
cmp    $0x0,%eax
jne    12bb <sub_from24digit+0x15b>
mov    0x2d3f(%rip),%rax
mov    (%rax),%edi
lea    0xdb5(%rip),%rsi
call   1080 <fprintf@plt>
mov    0x2d22(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x2c(%rbp)
jmp    12c0 <sub_from24digit+0x160>
jmp    12c5 <sub_from24digit+0x165>
mov    -0x2c(%rbp),%eax
mov    0x2d09(%rip),%rcx
cmp    (%rcx),%eax
je     1313 <sub_from24digit+0x1b3>
movsbl -0x21(%rbp),%edi
call   1030 <base24_digitToInt@plt>
mov    %eax,-0x28(%rbp)
cmpl   $0xffffffff,-0x28(%rbp)
jne    130e <sub_from24digit+0x1ae>
mov    0x2cec(%rip),%rax
mov    (%rax),%edi
lea    0xd7c(%rip),%rsi
call   1080 <fprintf@plt>
mov    0x2ccf(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x2c(%rbp)
jmp    1313 <sub_from24digit+0x1b3>
mov    -0x2c(%rbp),%eax
mov    0x2cbb(%rip),%rcx
cmp    (%rcx),%eax
je     1344 <sub_from24digit+0x1e4>
movsbl -0x21(%rbp),%esi
lea    0xd6c(%rip),%rdi
call   1050 <printf@plt>
mov    -0x28(%rbp),%esi
lea    0xd71(%rip),%rdi
call   1050 <printf@plt>
mov    -0x2c(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sub_from24digit>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %edi,%ebp
mov    0x2e5d(%rip),%rax
mov    (%rax),%r15d
call   1040 <getCustomCount@plt>
cmp    $0x2,%eax
jne    1198 <sub_from24digit+0x38>
mov    0x2e51(%rip),%r14
mov    (%r14),%eax
cmp    %eax,%r15d
jne    11bb <sub_from24digit+0x5b>
xor    %ebx,%ebx
cmp    %eax,%r15d
je     11d5 <sub_from24digit+0x75>
jmp    11dd <sub_from24digit+0x7d>
mov    0x2e41(%rip),%rax
mov    (%rax),%edi
lea    0xe58(%rip),%rsi
call   1080 <fprintf@plt>
mov    0x2e24(%rip),%rax
mov    (%rax),%eax
jmp    1257 <sub_from24digit+0xf7>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    $0x1,%edx
call   1060 <getCustom@plt>
mov    %rax,%rbx
mov    (%r14),%eax
cmp    %eax,%r15d
jne    11dd <sub_from24digit+0x7d>
mov    %r15d,%eax
jmp    1257 <sub_from24digit+0xf7>
mov    (%rbx),%cl
test   %cl,%cl
je     122c <sub_from24digit+0xcc>
add    $0x1,%rbx
xor    %ebp,%ebp
jmp    11ff <sub_from24digit+0x9f>
nopl   0x0(%rax,%rax,1)
movzbl -0x1(%rbx),%ebp
movzbl (%rbx),%ecx
add    $0x1,%rbx
test   %cl,%cl
je     1222 <sub_from24digit+0xc2>
movsbl %cl,%edi
call   1070 <isspace@plt>
test   %eax,%eax
jne    11f4 <sub_from24digit+0x94>
test   %bpl,%bpl
je     11f0 <sub_from24digit+0x90>
mov    0x2dc9(%rip),%rax
mov    (%rax),%edi
lea    0xe16(%rip),%rsi
jmp    1248 <sub_from24digit+0xe8>
mov    (%r14),%eax
cmp    %eax,%r15d
jne    1233 <sub_from24digit+0xd3>
jmp    1252 <sub_from24digit+0xf2>
xor    %ebp,%ebp
cmp    %eax,%r15d
je     1252 <sub_from24digit+0xf2>
test   %bpl,%bpl
jne    1252 <sub_from24digit+0xf2>
mov    0x2da1(%rip),%rax
mov    (%rax),%edi
lea    0xe17(%rip),%rsi
call   1080 <fprintf@plt>
mov    (%r14),%eax
jmp    1257 <sub_from24digit+0xf7>
cmp    %eax,%r15d
jne    1262 <sub_from24digit+0x102>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
movsbl %bpl,%ebp
mov    %ebp,%edi
call   1030 <base24_digitToInt@plt>
mov    %rax,%rbx
cmp    $0xffffffff,%ebx
je     129f <sub_from24digit+0x13f>
cmp    (%r14),%r15d
je     11d5 <sub_from24digit+0x75>
lea    0xe17(%rip),%rdi
mov    %ebp,%esi
call   1050 <printf@plt>
lea    0xe1d(%rip),%rdi
mov    %ebx,%esi
call   1050 <printf@plt>
jmp    11d5 <sub_from24digit+0x75>
mov    0x2d3a(%rip),%rax
mov    (%rax),%edi
lea    0xdca(%rip),%rsi
jmp    1248 <sub_from24digit+0xe8>

LLVM IR (-O0):
@EXIT_SUCCESS = global i32 0
@stderr = global i32 0
@.str = [54 x i8] c"from24digit expects exactly one additional argument!\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [41 x i8] c"Provide no more than one base-24 digit!\0A\00"
@.str.2 = [26 x i8] c"Provide a base-24 digit!\0A\00"
@.str.3 = [35 x i8] c"Could not parse as base-24 digit!\0A\00"
@.str.4 = [20 x i8] c"Base-24 digit: %c\0A\00"
@.str.5 = [20 x i8] c"Decimal value: %d\0A\00"
define i32 @sub_from24digit(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8**
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8
%8 = alloca i32
%9 = alloca i32
store i32 %0, i32* %3
store i8** %1, i8*** %4
store i8* null, i8** %5
store i8* null, i8** %6
store i8 0, i8* %7
store i32 0, i32* %8
%10 = load i32, i32* @EXIT_SUCCESS
store i32 %10, i32* %9
%11 = load i32, i32* %3
%12 = call i32 @getCustomCount(i32 %11)
%13 = icmp ne i32 %12, 2
br i1 %13, label %14, label %18
14: ; preds = %2
%15 = load i32, i32* @stderr
%16 = call i32 @fprintf(i32 %15, i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str, i64 0, i64 0))
%17 = load i32, i32* @EXIT_FAILURE
store i32 %17, i32* %9
br label %18
18: ; preds = %14, %2
%19 = load i32, i32* %9
%20 = load i32, i32* @EXIT_FAILURE
%21 = icmp ne i32 %19, %20
br i1 %21, label %22, label %26
22: ; preds = %18
%23 = load i32, i32* %3
%24 = load i8**, i8*** %4
%25 = call i8* @getCustom(i32 %23, i8** %24, i32 1)
store i8* %25, i8** %5
br label %26
26: ; preds = %22, %18
%27 = load i32, i32* %9
%28 = load i32, i32* @EXIT_FAILURE
%29 = icmp ne i32 %27, %28
br i1 %29, label %30, label %70
30: ; preds = %26
%31 = load i8*, i8** %5
store i8* %31, i8** %6
br label %32
32: ; preds = %53, %30
%33 = load i8*, i8** %6
%34 = load i8, i8* %33
%35 = sext i8 %34 to i32
%36 = icmp ne i32 %35, 0
br i1 %36, label %37, label %56
37: ; preds = %32
%38 = load i8*, i8** %6
%39 = load i8, i8* %38
%40 = call i32 @isspace(i8 signext %39)
%41 = icmp ne i32 %40, 0
br i1 %41, label %53, label %42
42: ; preds = %37
%43 = load i8, i8* %7
%44 = sext i8 %43 to i32
%45 = icmp ne i32 %44, 0
br i1 %45, label %46, label %50
46: ; preds = %42
%47 = load i32, i32* @stderr
%48 = call i32 @fprintf(i32 %47, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.1, i64 0, i64 0))
%49 = load i32, i32* @EXIT_FAILURE
store i32 %49, i32* %9
br label %56
50: ; preds = %42
%51 = load i8*, i8** %6
%52 = load i8, i8* %51
store i8 %52, i8* %7
br label %53
53: ; preds = %50, %37
%54 = load i8*, i8** %6
%55 = getelementptr inbounds i8, i8* %54, i32 1
store i8* %55, i8** %6
br label %32
56: ; preds = %46, %32
%57 = load i32, i32* %9
%58 = load i32, i32* @EXIT_FAILURE
%59 = icmp ne i32 %57, %58
br i1 %59, label %60, label %69
60: ; preds = %56
%61 = load i8, i8* %7
%62 = sext i8 %61 to i32
%63 = icmp eq i32 %62, 0
br i1 %63, label %64, label %68
64: ; preds = %60
%65 = load i32, i32* @stderr
%66 = call i32 @fprintf(i32 %65, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0))
%67 = load i32, i32* @EXIT_FAILURE
store i32 %67, i32* %9
br label %68
68: ; preds = %64, %60
br label %69
69: ; preds = %68, %56
br label %70
70: ; preds = %69, %26
%71 = load i32, i32* %9
%72 = load i32, i32* @EXIT_FAILURE
%73 = icmp ne i32 %71, %72
br i1 %73, label %74, label %85
74: ; preds = %70
%75 = load i8, i8* %7
%76 = call i64 @base24_digitToInt(i8 signext %75)
%77 = trunc i64 %76 to i32
store i32 %77, i32* %8
%78 = load i32, i32* %8
%79 = icmp eq i32 %78, -1
br i1 %79, label %80, label %84
80: ; preds = %74
%81 = load i32, i32* @stderr
%82 = call i32 @fprintf(i32 %81, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.3, i64 0, i64 0))
%83 = load i32, i32* @EXIT_FAILURE
store i32 %83, i32* %9
br label %84
84: ; preds = %80, %74
br label %85
85: ; preds = %84, %70
%86 = load i32, i32* %9
%87 = load i32, i32* @EXIT_FAILURE
%88 = icmp ne i32 %86, %87
br i1 %88, label %89, label %95
89: ; preds = %85
%90 = load i8, i8* %7
%91 = sext i8 %90 to i32
%92 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0), i32 %91)
%93 = load i32, i32* %8
%94 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.5, i64 0, i64 0), i32 %93)
br label %95
95: ; preds = %89, %85
%96 = load i32, i32* %9
ret i32 %96
}

LLVM IR (-O2):
@EXIT_SUCCESS = global i32 0
@stderr = global i32 0
@.str = [54 x i8] c"from24digit expects exactly one additional argument!\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [41 x i8] c"Provide no more than one base-24 digit!\0A\00"
@.str.2 = [26 x i8] c"Provide a base-24 digit!\0A\00"
@.str.3 = [35 x i8] c"Could not parse as base-24 digit!\0A\00"
@.str.4 = [20 x i8] c"Base-24 digit: %c\0A\00"
@.str.5 = [20 x i8] c"Decimal value: %d\0A\00"
define i32 @sub_from24digit(i32 %0, i8** %1) {
%3 = load i32, i32* @EXIT_SUCCESS
%4 = tail call i32 @getCustomCount(i32 %0)
%5 = icmp eq i32 %4, 2
br i1 %5, label %10, label %6
6: ; preds = %2
%7 = load i32, i32* @stderr
%8 = tail call i32 @fprintf(i32 %7, i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str, i64 0, i64 0))
%9 = load i32, i32* @EXIT_FAILURE
br label %71
10: ; preds = %2
%11 = load i32, i32* @EXIT_FAILURE
%12 = icmp eq i32 %3, %11
br i1 %12, label %16, label %13
13: ; preds = %10
%14 = tail call i8* @getCustom(i32 %0, i8** %1, i32 1)
%15 = load i32, i32* @EXIT_FAILURE
br label %16
16: ; preds = %13, %10
%17 = phi i32 [ %15, %13 ], [ %11, %10 ]
%18 = phi i8* [ %14, %13 ], [ null, %10 ]
%19 = icmp eq i32 %3, %17
br i1 %19, label %71, label %20
20: ; preds = %16
%21 = load i8, i8* %18
%22 = icmp eq i8 %21, 0
br i1 %22, label %44, label %23
23: ; preds = %20, %37
%24 = phi i8 [ %40, %37 ], [ %21, %20 ]
%25 = phi i8 [ %38, %37 ], [ 0, %20 ]
%26 = phi i8* [ %39, %37 ], [ %18, %20 ]
%27 = tail call i32 @isspace(i8 signext %24)
%28 = icmp eq i32 %27, 0
br i1 %28, label %29, label %37
29: ; preds = %23
%30 = icmp eq i8 %25, 0
br i1 %30, label %35, label %31
31: ; preds = %29
%32 = load i32, i32* @stderr
%33 = tail call i32 @fprintf(i32 %32, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.1, i64 0, i64 0))
%34 = load i32, i32* @EXIT_FAILURE
br label %71
35: ; preds = %29
%36 = load i8, i8* %26
br label %37
37: ; preds = %35, %23
%38 = phi i8 [ %25, %23 ], [ %36, %35 ]
%39 = getelementptr inbounds i8, i8* %26, i64 1
%40 = load i8, i8* %39
%41 = icmp eq i8 %40, 0
br i1 %41, label %42, label %23
42: ; preds = %37
%43 = load i32, i32* @EXIT_FAILURE
br label %44
44: ; preds = %42, %20
%45 = phi i32 [ %17, %20 ], [ %43, %42 ]
%46 = phi i8 [ 0, %20 ], [ %38, %42 ]
%47 = icmp ne i32 %3, %45
%48 = icmp eq i8 %46, 0
%49 = select i1 %47, i1 %48, i1 false
br i1 %49, label %50, label %54
50: ; preds = %44
%51 = load i32, i32* @stderr
%52 = tail call i32 @fprintf(i32 %51, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0))
%53 = load i32, i32* @EXIT_FAILURE
br label %71
54: ; preds = %44
%55 = icmp eq i32 %3, %45
br i1 %55, label %71, label %56
56: ; preds = %54
%57 = tail call i64 @base24_digitToInt(i8 signext %46)
%58 = trunc i64 %57 to i32
%59 = icmp eq i32 %58, -1
br i1 %59, label %60, label %64
60: ; preds = %56
%61 = load i32, i32* @stderr
%62 = tail call i32 @fprintf(i32 %61, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.3, i64 0, i64 0))
%63 = load i32, i32* @EXIT_FAILURE
br label %71
64: ; preds = %56
%65 = load i32, i32* @EXIT_FAILURE
%66 = icmp eq i32 %3, %65
br i1 %66, label %71, label %67
67: ; preds = %64
%68 = sext i8 %46 to i32
%69 = tail call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0), i32 %68)
%70 = tail call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.5, i64 0, i64 0), i32 %58)
br label %71
71: ; preds = %6, %31, %16, %50, %54, %60, %67, %64
%72 = phi i32 [ %3, %67 ], [ %3, %64 ], [ %45, %54 ], [ %63, %60 ], [ %9, %6 ], [ %34, %31 ], [ %3, %16 ], [ %53, %50 ]
ret i32 %72
}