#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 /*<<< orphan*/ dasm_read_imm_16(int);
int /*<<< orphan*/ dasm_read_imm_32(int);
int /*<<< orphan*/ dasm_read_imm_8(int);
char *make_signed_hex_str_16(int /*<<< orphan*/);
char *make_signed_hex_str_32(int /*<<< orphan*/);
char *make_signed_hex_str_8(int /*<<< orphan*/);
int /*<<< orphan*/ sprintf(char *, char *, char *);
char *get_imm_str_s(unsigned int size) {
  static char str[22];
  if (size == 0)
    sprintf(str, "#%s", make_signed_hex_str_8(dasm_read_imm_8(2)));
  else if (size == 1)
    sprintf(str, "#%s", make_signed_hex_str_16(dasm_read_imm_16(2)));
  else
    sprintf(str, "#%s", make_signed_hex_str_32(dasm_read_imm_32(4)));
  return str;
}


x86 assembly (clang, -O0):
<get_imm_str_s>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
cmpl   $0x0,-0x4(%rbp)
jne    11b1 <get_imm_str_s+0x41>
mov    $0x2,%edi
call   1030 <dasm_read_imm_8@plt>
mov    %eax,%edi
call   1040 <make_signed_hex_str_8@plt>
mov    %rax,%rdx
lea    0x2ed0(%rip),%rdi
lea    0xe59(%rip),%rsi
call   1090 <sprintf@plt>
jmp    1213 <get_imm_str_s+0xa3>
cmpl   $0x1,-0x4(%rbp)
jne    11e7 <get_imm_str_s+0x77>
mov    $0x2,%edi
call   1050 <dasm_read_imm_16@plt>
mov    %eax,%edi
call   1060 <make_signed_hex_str_16@plt>
mov    %rax,%rdx
lea    0x2e9a(%rip),%rdi
lea    0xe23(%rip),%rsi
call   1090 <sprintf@plt>
jmp    120e <get_imm_str_s+0x9e>
mov    $0x4,%edi
call   1080 <dasm_read_imm_32@plt>
mov    %eax,%edi
call   1070 <make_signed_hex_str_32@plt>
mov    %rax,%rdx
lea    0x2e6e(%rip),%rdi
lea    0xdf7(%rip),%rsi
call   1090 <sprintf@plt>
jmp    1213 <get_imm_str_s+0xa3>
lea    0x2e56(%rip),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_imm_str_s>:
push   %rbx
cmp    $0x1,%edi
je     118d <get_imm_str_s+0x1d>
test   %edi,%edi
jne    11a0 <get_imm_str_s+0x30>
mov    $0x2,%edi
call   1030 <dasm_read_imm_8@plt>
mov    %eax,%edi
call   1040 <make_signed_hex_str_8@plt>
jmp    11b1 <get_imm_str_s+0x41>
mov    $0x2,%edi
call   1050 <dasm_read_imm_16@plt>
mov    %eax,%edi
call   1060 <make_signed_hex_str_16@plt>
jmp    11b1 <get_imm_str_s+0x41>
mov    $0x4,%edi
call   1080 <dasm_read_imm_32@plt>
mov    %eax,%edi
call   1070 <make_signed_hex_str_32@plt>
lea    0x2eb8(%rip),%rbx
lea    0xe41(%rip),%rsi
mov    %rbx,%rdi
mov    %rax,%rdx
call   1090 <sprintf@plt>
mov    %rbx,%rax
pop    %rbx
ret

LLVM IR (-O0):
@get_imm_str_s.str = internal global [22 x i8] zeroinitializer
@.str = [4 x i8] c"#%s\00"
define i8* @get_imm_str_s(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = load i32, i32* %2
%4 = icmp eq i32 %3, 0
br i1 %4, label %5, label %9
5: ; preds = %1
%6 = call i32 @dasm_read_imm_8(i32 2)
%7 = call i8* @make_signed_hex_str_8(i32 %6)
%8 = call i32 @sprintf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @get_imm_str_s.str, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %7)
br label %21
9: ; preds = %1
%10 = load i32, i32* %2
%11 = icmp eq i32 %10, 1
br i1 %11, label %12, label %16
12: ; preds = %9
%13 = call i32 @dasm_read_imm_16(i32 2)
%14 = call i8* @make_signed_hex_str_16(i32 %13)
%15 = call i32 @sprintf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @get_imm_str_s.str, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %14)
br label %20
16: ; preds = %9
%17 = call i32 @dasm_read_imm_32(i32 4)
%18 = call i8* @make_signed_hex_str_32(i32 %17)
%19 = call i32 @sprintf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @get_imm_str_s.str, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %18)
br label %20
20: ; preds = %16, %12
br label %21
21: ; preds = %20, %5
ret i8* getelementptr inbounds ([22 x i8], [22 x i8]* @get_imm_str_s.str, i64 0, i64 0)
}

LLVM IR (-O2):
@get_imm_str_s.str = internal global [22 x i8] zeroinitializer
@.str = [4 x i8] c"#%s\00"
define i8* @get_imm_str_s(i32 %0) {
switch i32 %0, label %8 [
i32 0, label %2
i32 1, label %5
]
2: ; preds = %1
%3 = tail call i32 @dasm_read_imm_8(i32 2)
%4 = tail call i8* @make_signed_hex_str_8(i32 %3)
br label %11
5: ; preds = %1
%6 = tail call i32 @dasm_read_imm_16(i32 2)
%7 = tail call i8* @make_signed_hex_str_16(i32 %6)
br label %11
8: ; preds = %1
%9 = tail call i32 @dasm_read_imm_32(i32 4)
%10 = tail call i8* @make_signed_hex_str_32(i32 %9)
br label %11
11: ; preds = %5, %8, %2
%12 = phi i8* [ %7, %5 ], [ %10, %8 ], [ %4, %2 ]
%13 = tail call i32 @sprintf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @get_imm_str_s.str, i64 0, i64 0), i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %12)
ret i8* getelementptr inbounds ([22 x i8], [22 x i8]* @get_imm_str_s.str, i64 0, i64 0)
}