#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 EOF;
int /*<<< orphan*/ exit(int);
int getchar();
int /*<<< orphan*/ printf(char *, ...);
int toupper(int);
int main() {
  int ch;
  while (1) {
    printf("Choose output format: A) decimal, B) hex: ");
    ch = toupper(getchar());
    if (ch == 'A' || ch == 'B')
      break;
    if (ch == EOF)
      exit(1);
    while (ch != '\n') {
      ch = getchar();
      if (ch == EOF)
        exit(1);
    }
  }
  printf("The value is ");
  if (ch == 'A')
    printf("The value is %d\n", 0x1234);
  if (ch == 'B')
    printf("The value is %x\n", 0x1234);
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeaa(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   1050 <getchar@plt>
mov    %eax,%edi
call   1030 <toupper@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x41,-0x8(%rbp)
je     1182 <main+0x42>
cmpl   $0x42,-0x8(%rbp)
jne    1187 <main+0x47>
jmp    11e2 <main+0xa2>
mov    -0x8(%rbp),%eax
mov    0x2e57(%rip),%rcx
cmp    (%rcx),%eax
jne    11a3 <main+0x63>
mov    $0x1,%edi
call   1060 <exit@plt>
jmp    11a8 <main+0x68>
cmpl   $0xa,-0x8(%rbp)
je     11dd <main+0x9d>
mov    $0x0,%al
call   1050 <getchar@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    0x2e22(%rip),%rcx
cmp    (%rcx),%eax
jne    11d8 <main+0x98>
mov    $0x1,%edi
call   1060 <exit@plt>
jmp    11a8 <main+0x68>
jmp    114f <main+0xf>
lea    0xe42(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
cmpl   $0x41,-0x8(%rbp)
jne    120d <main+0xcd>
lea    0xe38(%rip),%rdi
mov    $0x1234,%esi
mov    $0x0,%al
call   1040 <printf@plt>
cmpl   $0x42,-0x8(%rbp)
jne    122a <main+0xea>
lea    0xe2c(%rip),%rdi
mov    $0x1234,%esi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
lea    0xeb5(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
call   1050 <getchar@plt>
mov    %eax,%edi
call   1030 <toupper@plt>
mov    %eax,%ebp
add    $0xffffffbf,%eax
cmp    $0x2,%eax
jae    118b <main+0x4b>
lea    0xeba(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
cmp    $0x41,%ebp
je     11ec <main+0xac>
cmp    $0x42,%ebp
jne    11ff <main+0xbf>
lea    0xec1(%rip),%rdi
jmp    11f3 <main+0xb3>
mov    0x2e56(%rip),%rbx
lea    0xe67(%rip),%r14
jmp    11c2 <main+0x82>
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
call   1050 <getchar@plt>
mov    %eax,%edi
call   1030 <toupper@plt>
mov    %eax,%ebp
add    $0xffffffbf,%eax
cmp    $0x2,%eax
jb     116a <main+0x2a>
cmp    (%rbx),%ebp
je     11e2 <main+0xa2>
cs nopw 0x0(%rax,%rax,1)
cmp    $0xa,%ebp
je     11a0 <main+0x60>
xor    %eax,%eax
call   1050 <getchar@plt>
mov    %eax,%ebp
cmp    (%rbx),%eax
jne    11d0 <main+0x90>
mov    $0x1,%edi
call   1060 <exit@plt>
lea    0xe46(%rip),%rdi
mov    $0x1234,%esi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [43 x i8] c"Choose output format: A) decimal, B) hex: \00"
@EOF = global i32 0
@.str.1 = [14 x i8] c"The value is \00"
@.str.2 = [17 x i8] c"The value is %d\0A\00"
@.str.3 = [17 x i8] c"The value is %x\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
store i32 0, i32* %1
br label %3
3: ; preds = %0, %31
%4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str, i64 0, i64 0))
%5 = call i32 (...) @getchar()
%6 = call i32 @toupper(i32 %5)
store i32 %6, i32* %2
%7 = load i32, i32* %2
%8 = icmp eq i32 %7, 65
br i1 %8, label %12, label %9
9: ; preds = %3
%10 = load i32, i32* %2
%11 = icmp eq i32 %10, 66
br i1 %11, label %12, label %13
12: ; preds = %9, %3
br label %32
13: ; preds = %9
%14 = load i32, i32* %2
%15 = load i32, i32* @EOF
%16 = icmp eq i32 %14, %15
br i1 %16, label %17, label %19
17: ; preds = %13
%18 = call i32 @exit(i32 1)
unreachable
19: ; preds = %13
br label %20
20: ; preds = %30, %19
%21 = load i32, i32* %2
%22 = icmp ne i32 %21, 10
br i1 %22, label %23, label %31
23: ; preds = %20
%24 = call i32 (...) @getchar()
store i32 %24, i32* %2
%25 = load i32, i32* %2
%26 = load i32, i32* @EOF
%27 = icmp eq i32 %25, %26
br i1 %27, label %28, label %30
28: ; preds = %23
%29 = call i32 @exit(i32 1)
unreachable
30: ; preds = %23
br label %20
31: ; preds = %20
br label %3
32: ; preds = %12
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
%34 = load i32, i32* %2
%35 = icmp eq i32 %34, 65
br i1 %35, label %36, label %38
36: ; preds = %32
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i32 4660)
br label %38
38: ; preds = %36, %32
%39 = load i32, i32* %2
%40 = icmp eq i32 %39, 66
br i1 %40, label %41, label %43
41: ; preds = %38
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0), i32 4660)
br label %43
43: ; preds = %41, %38
ret i32 0
}

LLVM IR (-O2):
@.str = [43 x i8] c"Choose output format: A) decimal, B) hex: \00"
@EOF = global i32 0
@.str.1 = [14 x i8] c"The value is \00"
@.str.2 = [17 x i8] c"The value is %d\0A\00"
@.str.3 = [17 x i8] c"The value is %x\0A\00"
define i32 @main() {
%1 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @.str, i64 0, i64 0))
%2 = tail call i32 (...) @getchar()
%3 = tail call i32 @toupper(i32 %2)
%4 = add i32 %3, -65
%5 = icmp ult i32 %4, 2
br i1 %5, label %27, label %12
6: ; preds = %18
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @.str, i64 0, i64 0))
%8 = tail call i32 (...) @getchar()
%9 = tail call i32 @toupper(i32 %8)
%10 = add i32 %9, -65
%11 = icmp ult i32 %10, 2
br i1 %11, label %27, label %12
12: ; preds = %0, %6
%13 = phi i32 [ %9, %6 ], [ %3, %0 ]
%14 = load i32, i32* @EOF
%15 = icmp eq i32 %13, %14
br i1 %15, label %16, label %18
16: ; preds = %12
%17 = tail call i32 @exit(i32 1)
unreachable
18: ; preds = %12, %21
%19 = phi i32 [ %22, %21 ], [ %13, %12 ]
%20 = icmp eq i32 %19, 10
br i1 %20, label %6, label %21
21: ; preds = %18
%22 = tail call i32 (...) @getchar()
%23 = load i32, i32* @EOF
%24 = icmp eq i32 %22, %23
br i1 %24, label %25, label %18
25: ; preds = %21
%26 = tail call i32 @exit(i32 1)
unreachable
27: ; preds = %6, %0
%28 = phi i32 [ %3, %0 ], [ %9, %6 ]
%29 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
switch i32 %28, label %34 [
i32 65, label %31
i32 66, label %30
]
30: ; preds = %27
br label %31
31: ; preds = %27, %30
%32 = phi i8* [ getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0), %30 ], [ getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), %27 ]
%33 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) %32, i32 4660)
br label %34
34: ; preds = %31, %27
ret i32 0
}