#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 */
char *__format_uint(int, int);
int /*<<< orphan*/ free(char *);
char *strvcat(char *, char *, int /*<<< orphan*/ *);
char *__format_int(int value, int flags) {
  char *string, *temp;
  if (value < 0) {
    temp = __format_uint(-value, flags);
    string = strvcat("-", temp, NULL);
    free(temp);
  } else {
    string = __format_uint(value, flags);
  }
  return string;
}


x86 assembly (clang, -O0):
<__format_int>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
cmpl   $0x0,-0x4(%rbp)
jge    117f <__format_int+0x4f>
xor    %edi,%edi
sub    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
call   1050 <__format_uint@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rsi
lea    0xe9c(%rip),%rdi
xor    %eax,%eax
mov    %eax,%edx
call   1040 <strvcat@plt>
mov    %rax,-0x10(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
jmp    118e <__format_int+0x5e>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
call   1050 <__format_uint@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<__format_int>:
test   %edi,%edi
js     1139 <__format_int+0x9>
jmp    1050 <__format_uint@plt>
push   %r14
push   %rbx
push   %rax
neg    %edi
call   1050 <__format_uint@plt>
mov    %rax,%rbx
lea    0xeb2(%rip),%rdi
mov    %rax,%rsi
xor    %edx,%edx
call   1040 <strvcat@plt>
mov    %rax,%r14
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [2 x i8] c"-\00"
define i8* @__format_int(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8*
store i32 %0, i32* %3
store i32 %1, i32* %4
%7 = load i32, i32* %3
%8 = icmp slt i32 %7, 0
br i1 %8, label %9, label %18
9: ; preds = %2
%10 = load i32, i32* %3
%11 = sub nsw i32 0, %10
%12 = load i32, i32* %4
%13 = call i8* @__format_uint(i32 %11, i32 %12)
store i8* %13, i8** %6
%14 = load i8*, i8** %6
%15 = call i8* @strvcat(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8* %14, i32* null)
store i8* %15, i8** %5
%16 = load i8*, i8** %6
%17 = call i32 @free(i8* %16)
br label %22
18: ; preds = %2
%19 = load i32, i32* %3
%20 = load i32, i32* %4
%21 = call i8* @__format_uint(i32 %19, i32 %20)
store i8* %21, i8** %5
br label %22
22: ; preds = %18, %9
%23 = load i8*, i8** %5
ret i8* %23
}

LLVM IR (-O2):
@.str = [2 x i8] c"-\00"
define i8* @__format_int(i32 %0, i32 %1) {
%3 = icmp slt i32 %0, 0
br i1 %3, label %4, label %9
4: ; preds = %2
%5 = sub nsw i32 0, %0
%6 = tail call i8* @__format_uint(i32 %5, i32 %1)
%7 = tail call i8* @strvcat(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8* %6, i32* null)
%8 = tail call i32 @free(i8* %6)
br label %11
9: ; preds = %2
%10 = tail call i8* @__format_uint(i32 %0, i32 %1)
br label %11
11: ; preds = %9, %4
%12 = phi i8* [ %7, %4 ], [ %10, %9 ]
ret i8* %12
}