#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 *, long long);
scalar_t__ strcmp(char *, char *);
int main(int argc, char **argv) {
  long long l;
  unsigned long long u;
  char buffer[64];
  if (sizeof(long long) != 8)
    return 3;
  l = 123456789123456789LL;
  buffer[0] = '\0';
  sprintf(buffer, "%lld", l);
  if (strcmp(buffer, "123456789123456789") == 0)
    return 0;
  buffer[0] = '\0';
  sprintf(buffer, "%qd", l);
  if (strcmp(buffer, "123456789123456789") == 0)
    return 1;
  return 2;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movabs $0x1b69b4bacd05f15,%rax
9b b6 01
mov    %rax,-0x18(%rbp)
movb   $0x0,-0x60(%rbp)
lea    -0x60(%rbp),%rdi
mov    -0x18(%rbp),%rdx
lea    0xea9(%rip),%rsi
call   1040 <sprintf@plt>
lea    -0x60(%rbp),%rdi
lea    0xe9e(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    1182 <main+0x62>
movl   $0x0,-0x4(%rbp)
jmp    11c7 <main+0xa7>
movb   $0x0,-0x60(%rbp)
lea    -0x60(%rbp),%rdi
mov    -0x18(%rbp),%rdx
lea    0xe83(%rip),%rsi
call   1040 <sprintf@plt>
lea    -0x60(%rbp),%rdi
lea    0xe60(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    11c0 <main+0xa0>
movl   $0x1,-0x4(%rbp)
jmp    11c7 <main+0xa7>
movl   $0x2,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x48,%rsp
movabs $0x1b69b4bacd05f15,%r14
9b b6 01
movb   $0x0,(%rsp)
lea    0xec4(%rip),%rsi
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    %r14,%rdx
call   1040 <sprintf@plt>
lea    0xeb4(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     1194 <main+0x74>
movb   $0x0,(%rsp)
lea    0xeaf(%rip),%rsi
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    %r14,%rdx
call   1040 <sprintf@plt>
lea    0xe87(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
cmp    $0x1,%rax
mov    $0x2,%eax
sbb    $0x0,%eax
jmp    1196 <main+0x76>
xor    %eax,%eax
add    $0x48,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [5 x i8] c"%lld\00"
@.str.1 = [19 x i8] c"123456789123456789\00"
@.str.2 = [4 x i8] c"%qd\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i64
%7 = alloca i64
%8 = alloca [64 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i64 123456789123456789, i64* %6
%9 = getelementptr inbounds [64 x i8], [64 x i8]* %8, i64 0, i64 0
store i8 0, i8* %9
%10 = getelementptr inbounds [64 x i8], [64 x i8]* %8, i64 0, i64 0
%11 = load i64, i64* %6
%12 = call i32 @sprintf(i8* %10, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i64 %11)
%13 = getelementptr inbounds [64 x i8], [64 x i8]* %8, i64 0, i64 0
%14 = call i64 @strcmp(i8* %13, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0))
%15 = icmp eq i64 %14, 0
br i1 %15, label %16, label %17
16: ; preds = %2
store i32 0, i32* %3
br label %27
17: ; preds = %2
%18 = getelementptr inbounds [64 x i8], [64 x i8]* %8, i64 0, i64 0
store i8 0, i8* %18
%19 = getelementptr inbounds [64 x i8], [64 x i8]* %8, i64 0, i64 0
%20 = load i64, i64* %6
%21 = call i32 @sprintf(i8* %19, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i64 %20)
%22 = getelementptr inbounds [64 x i8], [64 x i8]* %8, i64 0, i64 0
%23 = call i64 @strcmp(i8* %22, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0))
%24 = icmp eq i64 %23, 0
br i1 %24, label %25, label %26
25: ; preds = %17
store i32 1, i32* %3
br label %27
26: ; preds = %17
store i32 2, i32* %3
br label %27
27: ; preds = %26, %25, %16
%28 = load i32, i32* %3
ret i32 %28
}

LLVM IR (-O2):
@.str = [5 x i8] c"%lld\00"
@.str.1 = [19 x i8] c"123456789123456789\00"
@.str.2 = [4 x i8] c"%qd\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [64 x i8]
%4 = getelementptr inbounds [64 x i8], [64 x i8]* %3, i64 0, i64 0
store i8 0, i8* %4
%5 = call i32 @sprintf(i8* %4, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i64 123456789123456789)
%6 = call i64 @strcmp(i8* %4, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0))
%7 = icmp eq i64 %6, 0
br i1 %7, label %13, label %8
8: ; preds = %2
store i8 0, i8* %4
%9 = call i32 @sprintf(i8* %4, i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i64 123456789123456789)
%10 = call i64 @strcmp(i8* %4, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0))
%11 = icmp eq i64 %10, 0
%12 = select i1 %11, i32 1, i32 2
br label %13
13: ; preds = %8, %2
%14 = phi i32 [ 0, %2 ], [ %12, %8 ]
ret i32 %14
}