#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*/ sprintf(char *, char *, ...);
char *make_signed_hex_str_8(unsigned int val) {
  static char str[20];
  val &= 0xff;
  if (val == 0x80)
    sprintf(str, "-$80");
  else if (val & 0x80)
    sprintf(str, "-$%x", (0 - val) & 0x7f);
  else
    sprintf(str, "$%x", val & 0x7f);
  return str;
}


x86 assembly (clang, -O0):
<make_signed_hex_str_8>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%eax
and    $0xff,%eax
mov    %eax,-0x4(%rbp)
cmpl   $0x80,-0x4(%rbp)
jne    114d <make_signed_hex_str_8+0x3d>
lea    0x2f06(%rip),%rdi
lea    0xebf(%rip),%rsi
mov    $0x0,%al
call   1030 <sprintf@plt>
jmp    11a0 <make_signed_hex_str_8+0x90>
mov    -0x4(%rbp),%eax
and    $0x80,%eax
cmp    $0x0,%eax
je     1180 <make_signed_hex_str_8+0x70>
xor    %edx,%edx
sub    -0x4(%rbp),%edx
and    $0x7f,%edx
lea    0x2ed3(%rip),%rdi
lea    0xe91(%rip),%rsi
mov    $0x0,%al
call   1030 <sprintf@plt>
jmp    119b <make_signed_hex_str_8+0x8b>
mov    -0x4(%rbp),%edx
and    $0x7f,%edx
lea    0x2eb3(%rip),%rdi
lea    0xe72(%rip),%rsi
mov    $0x0,%al
call   1030 <sprintf@plt>
jmp    11a0 <make_signed_hex_str_8+0x90>
lea    0x2e99(%rip),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<make_signed_hex_str_8>:
push   %rax
mov    %edi,%edx
cmp    $0x80,%dl
jne    112b <make_signed_hex_str_8+0x1b>
movb   $0x0,0x2f25(%rip)
movl   $0x3038242d,0x2f17(%rip)
24 38 30
jmp    115d <make_signed_hex_str_8+0x4d>
test   $0x80,%dl
jne    1143 <make_signed_hex_str_8+0x33>
and    $0x7f,%edx
lea    0x2f06(%rip),%rdi
lea    0xec5(%rip),%rsi
jmp    1156 <make_signed_hex_str_8+0x46>
neg    %edx
and    $0x7f,%edx
lea    0x2ef1(%rip),%rdi
lea    0xeaf(%rip),%rsi
xor    %eax,%eax
call   1030 <sprintf@plt>
lea    0x2edc(%rip),%rax
pop    %rcx
ret

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

LLVM IR (-O2):
@make_signed_hex_str_8.str = internal global [20 x i8] zeroinitializer
@.str = [5 x i8] c"-$80\00"
@.str.1 = [5 x i8] c"-$%x\00"
@.str.2 = [4 x i8] c"$%x\00"
define i8* @make_signed_hex_str_8(i32 %0) {
%2 = and i32 %0, 255
%3 = icmp eq i32 %2, 128
br i1 %3, label %4, label %5
4: ; preds = %1
tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 16 dereferenceable(5) getelementptr inbounds ([20 x i8], [20 x i8]* @make_signed_hex_str_8.str, i64 0, i64 0), i8* align 1 dereferenceable(5) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i64 5, i1 false)
br label %15
5: ; preds = %1
%6 = and i32 %0, 128
%7 = icmp eq i32 %6, 0
br i1 %7, label %12, label %8
8: ; preds = %5
%9 = sub i32 0, %0
%10 = and i32 %9, 127
%11 = tail call i32 (i8*, i8*, ...) @sprintf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @make_signed_hex_str_8.str, i64 0, i64 0), i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %10)
br label %15
12: ; preds = %5
%13 = and i32 %0, 127
%14 = tail call i32 (i8*, i8*, ...) @sprintf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @make_signed_hex_str_8.str, i64 0, i64 0), i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %13)
br label %15
15: ; preds = %8, %12, %4
ret i8* getelementptr inbounds ([20 x i8], [20 x i8]* @make_signed_hex_str_8.str, i64 0, i64 0)
}