#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*/ printf(char *, char *, char *);
int /*<<< orphan*/ sprintf(char *, char *, ...);
int /*<<< orphan*/ strcat(char *, char *);
int strlen(char *);
void format_data(char *type, long int *nb) {
  static char buf[25];
  static char buf_res[25];
  int n;
  sprintf(buf, "%lx", *nb);
  sprintf(buf_res, "%s:0x", type);
  n = 20 - strlen(buf_res) - strlen(buf);
  while (n-- > 0)
    strcat(buf_res, "0");
  printf("%s%s", buf_res, buf);
}


x86 assembly (clang, -O0):
<format_data>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0x2ef2(%rip),%rdi
lea    0xe9b(%rip),%rsi
mov    $0x0,%al
call   1060 <sprintf@plt>
mov    -0x8(%rbp),%rdx
lea    0x2ef9(%rip),%rdi
lea    0xe86(%rip),%rsi
mov    $0x0,%al
call   1060 <sprintf@plt>
lea    0x2ee4(%rip),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    $0x14,%eax
sub    %ecx,%eax
mov    %eax,-0x18(%rbp)
lea    0x2eac(%rip),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x14(%rbp)
cmp    $0x0,%eax
jle    11df <format_data+0x9f>
lea    0x2ea2(%rip),%rdi
lea    0xe35(%rip),%rsi
call   1050 <strcat@plt>
jmp    11b3 <format_data+0x73>
lea    0xe26(%rip),%rdi
lea    0x2e83(%rip),%rsi
lea    0x2e5c(%rip),%rdx
call   1040 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<format_data>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
mov    (%rsi),%rdx
lea    0x2efc(%rip),%r14
lea    0xea5(%rip),%rsi
mov    %r14,%rdi
xor    %eax,%eax
call   1060 <sprintf@plt>
lea    0x2f04(%rip),%r15
lea    0xe91(%rip),%rsi
mov    %r15,%rdi
mov    %rbx,%rdx
xor    %eax,%eax
call   1060 <sprintf@plt>
mov    %r15,%rdi
call   1030 <strlen@plt>
mov    %eax,%ebx
mov    %r14,%rdi
call   1030 <strlen@plt>
add    %ebx,%eax
mov    $0x14,%ecx
sub    %eax,%ecx
test   %ecx,%ecx
jle    11d3 <format_data+0x93>
mov    $0x15,%ebp
sub    %eax,%ebp
lea    0x2ec3(%rip),%r14
lea    0xe56(%rip),%rbx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r14,%rdi
mov    %rbx,%rsi
call   1050 <strcat@plt>
add    $0xffffffff,%ebp
cmp    $0x1,%ebp
ja     11c0 <format_data+0x80>
lea    0xe32(%rip),%rdi
lea    0x2e8f(%rip),%rsi
lea    0x2e68(%rip),%rdx
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <printf@plt>

LLVM IR (-O0):
@format_data.buf = internal global [25 x i8] zeroinitializer
@format_data.buf_res = internal global [25 x i8] zeroinitializer
@.str = [4 x i8] c"%lx\00"
@.str.1 = [6 x i8] c"%s:0x\00"
@.str.2 = [2 x i8] c"0\00"
@.str.3 = [5 x i8] c"%s%s\00"
define void @format_data(i8* %0, i64* %1) {
%3 = alloca i8*
%4 = alloca i64*
%5 = alloca i32
store i8* %0, i8** %3
store i64* %1, i64** %4
%6 = load i64*, i64** %4
%7 = load i64, i64* %6
%8 = call i32 (i8*, i8*, ...) @sprintf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @format_data.buf, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i64 %7)
%9 = load i8*, i8** %3
%10 = call i32 (i8*, i8*, ...) @sprintf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @format_data.buf_res, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %9)
%11 = call i32 @strlen(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @format_data.buf_res, i64 0, i64 0))
%12 = sub nsw i32 20, %11
%13 = call i32 @strlen(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @format_data.buf, i64 0, i64 0))
%14 = sub nsw i32 %12, %13
store i32 %14, i32* %5
br label %15
15: ; preds = %19, %2
%16 = load i32, i32* %5
%17 = add nsw i32 %16, -1
store i32 %17, i32* %5
%18 = icmp sgt i32 %16, 0
br i1 %18, label %19, label %21
19: ; preds = %15
%20 = call i32 @strcat(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @format_data.buf_res, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %15
21: ; preds = %15
%22 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([25 x i8], [25 x i8]* @format_data.buf_res, i64 0, i64 0), i8* getelementptr inbounds ([25 x i8], [25 x i8]* @format_data.buf, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@format_data.buf = internal global [25 x i8] zeroinitializer
@format_data.buf_res = internal global [25 x i8] zeroinitializer
@.str = [4 x i8] c"%lx\00"
@.str.1 = [6 x i8] c"%s:0x\00"
@.str.2 = [2 x i8] c"0\00"
@.str.3 = [5 x i8] c"%s%s\00"
define void @format_data(i8* %0, i64* nocapture %1) {
%3 = load i64, i64* %1
%4 = tail call i32 (i8*, i8*, ...) @sprintf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @format_data.buf, i64 0, i64 0), i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i64 %3)
%5 = tail call i32 (i8*, i8*, ...) @sprintf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @format_data.buf_res, i64 0, i64 0), i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %0)
%6 = tail call i32 @strlen(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @format_data.buf_res, i64 0, i64 0))
%7 = tail call i32 @strlen(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @format_data.buf, i64 0, i64 0))
%8 = add i32 %6, %7
%9 = sub i32 20, %8
%10 = icmp sgt i32 %9, 0
br i1 %10, label %11, label %16
11: ; preds = %2, %11
%12 = phi i32 [ %13, %11 ], [ %9, %2 ]
%13 = add nsw i32 %12, -1
%14 = tail call i32 @strcat(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @format_data.buf_res, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%15 = icmp ugt i32 %12, 1
br i1 %15, label %11, label %16
16: ; preds = %11, %2
%17 = tail call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([25 x i8], [25 x i8]* @format_data.buf_res, i64 0, i64 0), i8* getelementptr inbounds ([25 x i8], [25 x i8]* @format_data.buf, i64 0, i64 0))
ret void
}