#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 uint;

/* Variables and functions */
int /*<<< orphan*/ fputs(char *, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ stderr;
void loada4(uint type, uint lsb, uint msb) {
  printf("\tMOV     a4, #0x%x\n", msb);
  switch (type) {
  case 0:
    printf("\tSUB     a4, a4, #0x%x\n", lsb);
    break;
  case 1:
    printf("\tADD     a4, a4, #0x%x\n", lsb);
    break;
  default:
    fputs("Internal error", stderr);
  }
}


x86 assembly (clang, -O0):
<loada4>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    -0xc(%rbp),%esi
lea    0xec5(%rip),%rdi
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
mov    %eax,-0x10(%rbp)
test   %eax,%eax
je     1164 <loada4+0x44>
jmp    1153 <loada4+0x33>
mov    -0x10(%rbp),%eax
sub    $0x1,%eax
je     1178 <loada4+0x58>
jmp    118c <loada4+0x6c>
mov    -0x8(%rbp),%esi
lea    0xea6(%rip),%rdi
call   1030 <printf@plt>
jmp    11a1 <loada4+0x81>
mov    -0x8(%rbp),%esi
lea    0xeaa(%rip),%rdi
call   1030 <printf@plt>
jmp    11a1 <loada4+0x81>
mov    0x2e4d(%rip),%rax
mov    (%rax),%esi
lea    0xea8(%rip),%rdi
call   1040 <fputs@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<loada4>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebx
mov    %edi,%ebp
lea    0xed2(%rip),%rdi
mov    %edx,%esi
call   1030 <printf@plt>
cmp    $0x1,%ebp
je     1147 <loada4+0x27>
test   %ebp,%ebp
jne    115b <loada4+0x3b>
lea    0xecf(%rip),%rdi
jmp    114e <loada4+0x2e>
lea    0xede(%rip),%rdi
mov    %ebx,%esi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1030 <printf@plt>
mov    0x2e7e(%rip),%rax
mov    (%rax),%esi
lea    0xed9(%rip),%rdi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1040 <fputs@plt>

LLVM IR (-O0):
@.str = [20 x i8] c"\09MOV a4,x%x\0A\00"
@.str.1 = [24 x i8] c"\09SUB a4, a4,x%x\0A\00"
@.str.2 = [24 x i8] c"\09ADD a4, a4,x%x\0A\00"
@.str.3 = [15 x i8] c"Internal error\00"
@stderr = global i32 0
define void @loada4(i32 %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%7 = load i32, i32* %6
%8 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i32 %7)
%9 = load i32, i32* %4
switch i32 %9, label %16 [
i32 0, label %10
i32 1, label %13
]
10: ; preds = %3
%11 = load i32, i32* %5
%12 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), i32 %11)
br label %19
13: ; preds = %3
%14 = load i32, i32* %5
%15 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0), i32 %14)
br label %19
16: ; preds = %3
%17 = load i32, i32* @stderr
%18 = call i32 @fputs(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0), i32 %17)
br label %19
19: ; preds = %16, %13, %10
ret void
}

LLVM IR (-O2):
@.str = [20 x i8] c"\09MOV a4,x%x\0A\00"
@.str.1 = [24 x i8] c"\09SUB a4, a4,x%x\0A\00"
@.str.2 = [24 x i8] c"\09ADD a4, a4,x%x\0A\00"
@.str.3 = [15 x i8] c"Internal error\00"
@stderr = global i32 0
define void @loada4(i32 %0, i32 %1, i32 %2) {
%4 = tail call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i32 %2)
switch i32 %0, label %9 [
i32 0, label %5
i32 1, label %7
]
5: ; preds = %3
%6 = tail call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), i32 %1)
br label %12
7: ; preds = %3
%8 = tail call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0), i32 %1)
br label %12
9: ; preds = %3
%10 = load i32, i32* @stderr
%11 = tail call i32 @fputs(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0), i32 %10)
br label %12
12: ; preds = %9, %7, %5
ret void
}