#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*/ abort();
int /*<<< orphan*/ printf(char *, int, long long);
int sscanf(char *, char *, long long *);
int main(int argc, char *argv[]) {
  long long int n;
  int ret;
  n = -1;
  ret = sscanf("1000", "%lld", &n);
  printf("%%lld: ret: %d, n: %Ld\n", ret, n);
  if (ret != 1 || n != 1000L)
    abort();
  n = -2;
  ret = sscanf("1000", "%llld", &n);
  printf("%%llld: ret: %d, n: %Ld\n", ret, n);
  if (ret > 0 || n >= 0L)
    abort();
  return 0;
}


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)
movq   $0xffffffffffffffff,-0x18(%rbp)
ff
lea    0xeab(%rip),%rdi
lea    0xea9(%rip),%rsi
lea    -0x18(%rbp),%rdx
call   1050 <sscanf@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%esi
mov    -0x18(%rbp),%rdx
lea    0xe94(%rip),%rdi
call   1040 <printf@plt>
cmpl   $0x1,-0x1c(%rbp)
jne    1193 <main+0x63>
cmpq   $0x3e8,-0x18(%rbp)
je     119a <main+0x6a>
mov    $0x0,%al
call   1030 <abort@plt>
movq   $0xfffffffffffffffe,-0x18(%rbp)
ff
lea    0xe57(%rip),%rdi
lea    0xe72(%rip),%rsi
lea    -0x18(%rbp),%rdx
call   1050 <sscanf@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%esi
mov    -0x18(%rbp),%rdx
lea    0xe5e(%rip),%rdi
call   1040 <printf@plt>
cmpl   $0x0,-0x1c(%rbp)
jg     11e4 <main+0xb4>
cmpq   $0x0,-0x18(%rbp)
jl     11eb <main+0xbb>
mov    $0x0,%al
call   1030 <abort@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
movq   $0xffffffffffffffff,0x8(%rsp)
ff ff
lea    0xebb(%rip),%rdi
lea    0xeb9(%rip),%rsi
lea    0x8(%rsp),%rdx
call   1050 <sscanf@plt>
mov    %eax,%ebx
mov    0x8(%rsp),%rdx
lea    0xea6(%rip),%rdi
mov    %eax,%esi
call   1040 <printf@plt>
cmp    $0x1,%ebx
jne    11c5 <main+0x95>
cmpq   $0x3e8,0x8(%rsp)
jne    11c5 <main+0x95>
movq   $0xfffffffffffffffe,0x8(%rsp)
ff ff
lea    0xe75(%rip),%rdi
lea    0xe90(%rip),%rsi
lea    0x8(%rsp),%rdx
call   1050 <sscanf@plt>
mov    %eax,%ebx
mov    0x8(%rsp),%rdx
lea    0xe7e(%rip),%rdi
mov    %eax,%esi
call   1040 <printf@plt>
test   %ebx,%ebx
jg     11c5 <main+0x95>
cmpq   $0x0,0x8(%rsp)
jns    11c5 <main+0x95>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret
xor    %eax,%eax
call   1030 <abort@plt>

LLVM IR (-O0):
@.str = [5 x i8] c"1000\00"
@.str.1 = [5 x i8] c"%lld\00"
@.str.2 = [24 x i8] c"%%lld: ret: %d, n: %Ld\0A\00"
@.str.3 = [6 x i8] c"%llld\00"
@.str.4 = [25 x i8] c"%%llld: ret: %d, n: %Ld\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i64
%7 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i64 -1, i64* %6
%8 = call i32 @sscanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i64* %6)
store i32 %8, i32* %7
%9 = load i32, i32* %7
%10 = load i64, i64* %6
%11 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0), i32 %9, i64 %10)
%12 = load i32, i32* %7
%13 = icmp ne i32 %12, 1
br i1 %13, label %17, label %14
14: ; preds = %2
%15 = load i64, i64* %6
%16 = icmp ne i64 %15, 1000
br i1 %16, label %17, label %19
17: ; preds = %14, %2
%18 = call i32 (...) @abort()
unreachable
19: ; preds = %14
store i64 -2, i64* %6
%20 = call i32 @sscanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i64* %6)
store i32 %20, i32* %7
%21 = load i32, i32* %7
%22 = load i64, i64* %6
%23 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i64 0, i64 0), i32 %21, i64 %22)
%24 = load i32, i32* %7
%25 = icmp sgt i32 %24, 0
br i1 %25, label %29, label %26
26: ; preds = %19
%27 = load i64, i64* %6
%28 = icmp sge i64 %27, 0
br i1 %28, label %29, label %31
29: ; preds = %26, %19
%30 = call i32 (...) @abort()
unreachable
31: ; preds = %26
ret i32 0
}

LLVM IR (-O2):
@.str = [5 x i8] c"1000\00"
@.str.1 = [5 x i8] c"%lld\00"
@.str.2 = [24 x i8] c"%%lld: ret: %d, n: %Ld\0A\00"
@.str.3 = [6 x i8] c"%llld\00"
@.str.4 = [25 x i8] c"%%llld: ret: %d, n: %Ld\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i64
%4 = bitcast i64* %3 to i8*
store i64 -1, i64* %3
%5 = call i32 @sscanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i64* %3)
%6 = load i64, i64* %3
%7 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0), i32 %5, i64 %6)
%8 = icmp ne i32 %5, 1
%9 = load i64, i64* %3
%10 = icmp ne i64 %9, 1000
%11 = select i1 %8, i1 true, i1 %10
br i1 %11, label %12, label %14
12: ; preds = %2
%13 = call i32 (...) @abort()
unreachable
14: ; preds = %2
store i64 -2, i64* %3
%15 = call i32 @sscanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i64* %3)
%16 = load i64, i64* %3
%17 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i64 0, i64 0), i32 %15, i64 %16)
%18 = icmp sgt i32 %15, 0
%19 = load i64, i64* %3
%20 = icmp sgt i64 %19, -1
%21 = select i1 %18, i1 true, i1 %20
br i1 %21, label %22, label %24
22: ; preds = %14
%23 = call i32 (...) @abort()
unreachable
24: ; preds = %14
ret i32 0
}