#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*/ atoi(char *);
int /*<<< orphan*/ atol(char *);
int bench_snprintf(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *);
int main(int argc, char *argv[]) {
  if (argc == 1 + 2) {
    return -bench_snprintf(atoi(argv[1]), atol(argv[2]));
  } else {
    printf("USAGE : bench_snprintf type count\n");
    return 7;
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x3,-0x8(%rbp)
jne    1195 <main+0x55>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1050 <atoi@plt>
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1040 <atol@plt>
mov    -0x14(%rbp),%edi
mov    %eax,%esi
call   1060 <bench_snprintf@plt>
mov    %eax,%ecx
xor    %eax,%eax
sub    %ecx,%eax
mov    %eax,-0x4(%rbp)
jmp    11a8 <main+0x68>
lea    0xe64(%rip),%rdi
call   1030 <printf@plt>
movl   $0x7,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
cmp    $0x3,%edi
jne    116c <main+0x2c>
mov    %rsi,%rbx
mov    0x8(%rsi),%rdi
call   1050 <atoi@plt>
mov    %eax,%ebp
mov    0x10(%rbx),%rdi
call   1040 <atol@plt>
mov    %ebp,%edi
mov    %eax,%esi
call   1060 <bench_snprintf@plt>
neg    %eax
jmp    117d <main+0x3d>
lea    0xe8d(%rip),%rdi
call   1030 <puts@plt>
mov    $0x7,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [35 x i8] c"USAGE : bench_snprintf type count\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%6 = load i32, i32* %4
%7 = icmp eq i32 %6, 3
br i1 %7, label %8, label %19
8: ; preds = %2
%9 = load i8**, i8*** %5
%10 = getelementptr inbounds i8*, i8** %9, i64 1
%11 = load i8*, i8** %10
%12 = call i32 @atoi(i8* %11)
%13 = load i8**, i8*** %5
%14 = getelementptr inbounds i8*, i8** %13, i64 2
%15 = load i8*, i8** %14
%16 = call i32 @atol(i8* %15)
%17 = call i32 @bench_snprintf(i32 %12, i32 %16)
%18 = sub nsw i32 0, %17
store i32 %18, i32* %3
br label %21
19: ; preds = %2
%20 = call i32 @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0))
store i32 7, i32* %3
br label %21
21: ; preds = %19, %8
%22 = load i32, i32* %3
ret i32 %22
}

LLVM IR (-O2):
@str = [34 x i8] c"USAGE : bench_snprintf type count\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 3
br i1 %3, label %4, label %13
4: ; preds = %2
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = load i8*, i8** %5
%7 = tail call i32 @atoi(i8* %6)
%8 = getelementptr inbounds i8*, i8** %1, i64 2
%9 = load i8*, i8** %8
%10 = tail call i32 @atol(i8* %9)
%11 = tail call i32 @bench_snprintf(i32 %7, i32 %10)
%12 = sub nsw i32 0, %11
br label %15
13: ; preds = %2
%14 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @str, i64 0, i64 0))
br label %15
15: ; preds = %13, %4
%16 = phi i32 [ %12, %4 ], [ 7, %13 ]
ret i32 %16
}