#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*/ Assert_real(int /*<<< orphan*/, char *, int, char *);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ sprintf(char *, char *, int, ...);
int /*<<< orphan*/ sscanf(char *, char *, int *);
void test_scanf_d() {
  char buf[100];
  int i, j;
  unsigned int failures = 0;
  unsigned int success = 0;
  for (i = -32767; i < 32767; i++) {
    if (i % 1000 == 0) {
      printf("%d ", i);
    }
    sprintf(buf, "%d", i);
    sscanf(buf, "%d", &j);
    if (i != j) {
      sprintf(buf, "Failed conversion for %d != %d", i, j);
      Assert_real((0),
                  "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
                  "outputs/2022-01-22/02-19-57/repos/bitfixer/bitfixer/refs/"
                  "heads/master/dg/z88dk/test/suites/stdio/scanf.c",
                  23, (buf));
    }
  }
}


x86 assembly (clang, -O0):
<test_scanf_d>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movl   $0x0,-0x7c(%rbp)
movl   $0x0,-0x80(%rbp)
movl   $0xffff8001,-0x74(%rbp)
cmpl   $0x7fff,-0x74(%rbp)
jge    1207 <test_scanf_d+0xc7>
mov    -0x74(%rbp),%eax
mov    $0x3e8,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    1190 <test_scanf_d+0x50>
mov    -0x74(%rbp),%esi
lea    0xe75(%rip),%rdi
call   1030 <printf@plt>
lea    -0x70(%rbp),%rdi
mov    -0x74(%rbp),%edx
lea    0xe82(%rip),%rsi
mov    $0x0,%al
call   1050 <sprintf@plt>
lea    -0x70(%rbp),%rdi
lea    0xe70(%rip),%rsi
lea    -0x78(%rbp),%rdx
call   1040 <sscanf@plt>
mov    -0x74(%rbp),%eax
cmp    -0x78(%rbp),%eax
je     11f4 <test_scanf_d+0xb4>
lea    -0x70(%rbp),%rdi
mov    -0x74(%rbp),%edx
mov    -0x78(%rbp),%ecx
lea    0xe2e(%rip),%rsi
mov    $0x0,%al
call   1050 <sprintf@plt>
lea    -0x70(%rbp),%rcx
xor    %edi,%edi
lea    0xe39(%rip),%rsi
mov    $0x17,%edx
call   1060 <Assert_real@plt>
jmp    11f9 <test_scanf_d+0xb9>
mov    -0x74(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x74(%rbp)
jmp    1160 <test_scanf_d+0x20>
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_scanf_d>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x78,%rsp
mov    $0xffff8001,%ebx
lea    0xec6(%rip),%r15
lea    0x10(%rsp),%r12
lea    0xc(%rsp),%r13
lea    0xe99(%rip),%rbp
lea    0xeb1(%rip),%r14
jmp    118b <test_scanf_d+0x4b>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
add    $0x1,%ebx
cmp    $0x7fff,%ebx
je     11f6 <test_scanf_d+0xb6>
imul   $0x26e978d5,%ebx,%eax
add    $0x10624d8,%eax
ror    $0x3,%eax
cmp    $0x418936,%eax
ja     11ae <test_scanf_d+0x6e>
lea    0xe59(%rip),%rdi
mov    %ebx,%esi
call   1030 <printf@plt>
mov    %r12,%rdi
mov    %r15,%rsi
mov    %ebx,%edx
xor    %eax,%eax
call   1050 <sprintf@plt>
mov    %r12,%rdi
mov    %r15,%rsi
mov    %r13,%rdx
call   1040 <sscanf@plt>
mov    0xc(%rsp),%ecx
cmp    %ecx,%ebx
je     1180 <test_scanf_d+0x40>
mov    %r12,%rdi
mov    %rbp,%rsi
mov    %ebx,%edx
xor    %eax,%eax
call   1050 <sprintf@plt>
xor    %edi,%edi
mov    %r14,%rsi
mov    $0x17,%edx
mov    %r12,%rcx
call   1060 <Assert_real@plt>
jmp    1180 <test_scanf_d+0x40>
add    $0x78,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%d \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [31 x i8] c"Failed conversion for %d != %d\00"
@.str.3 = [161 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/bitfixer/bitfixer/refs/heads/master/dg/z88dk/test/suites/stdio/scanf.c\00"
define void @test_scanf_d() {
%1 = alloca [100 x i8]
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %4
store i32 0, i32* %5
store i32 -32767, i32* %2
br label %6
6: ; preds = %33, %0
%7 = load i32, i32* %2
%8 = icmp slt i32 %7, 32767
br i1 %8, label %9, label %36
9: ; preds = %6
%10 = load i32, i32* %2
%11 = srem i32 %10, 1000
%12 = icmp eq i32 %11, 0
br i1 %12, label %13, label %16
13: ; preds = %9
%14 = load i32, i32* %2
%15 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %14)
br label %16
16: ; preds = %13, %9
%17 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%18 = load i32, i32* %2
%19 = call i32 (i8*, i8*, i32, ...) @sprintf(i8* %17, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %18)
%20 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%21 = call i32 @sscanf(i8* %20, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%22 = load i32, i32* %2
%23 = load i32, i32* %3
%24 = icmp ne i32 %22, %23
br i1 %24, label %25, label %32
25: ; preds = %16
%26 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%27 = load i32, i32* %2
%28 = load i32, i32* %3
%29 = call i32 (i8*, i8*, i32, ...) @sprintf(i8* %26, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0), i32 %27, i32 %28)
%30 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%31 = call i32 @Assert_real(i32 0, i8* getelementptr inbounds ([161 x i8], [161 x i8]* @.str.3, i64 0, i64 0), i32 23, i8* %30)
br label %32
32: ; preds = %25, %16
br label %33
33: ; preds = %32
%34 = load i32, i32* %2
%35 = add nsw i32 %34, 1
store i32 %35, i32* %2
br label %6
36: ; preds = %6
ret void
}

LLVM IR (-O2):
@.str = [4 x i8] c"%d \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [31 x i8] c"Failed conversion for %d != %d\00"
@.str.3 = [161 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/bitfixer/bitfixer/refs/heads/master/dg/z88dk/test/suites/stdio/scanf.c\00"
define void @test_scanf_d() {
%1 = alloca [100 x i8]
%2 = alloca i32
%3 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%4 = bitcast i32* %2 to i8*
br label %5
5: ; preds = %0, %19
%6 = phi i32 [ -32767, %0 ], [ %20, %19 ]
%7 = srem i32 %6, 1000
%8 = icmp eq i32 %7, 0
br i1 %8, label %9, label %11
9: ; preds = %5
%10 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %6)
br label %11
11: ; preds = %9, %5
%12 = call i32 (i8*, i8*, i32, ...) @sprintf(i8* %3, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %6)
%13 = call i32 @sscanf(i8* %3, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%14 = load i32, i32* %2
%15 = icmp eq i32 %6, %14
br i1 %15, label %19, label %16
16: ; preds = %11
%17 = call i32 (i8*, i8*, i32, ...) @sprintf(i8* %3, i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0), i32 %6, i32 %14)
%18 = call i32 @Assert_real(i32 0, i8* getelementptr inbounds ([161 x i8], [161 x i8]* @.str.3, i64 0, i64 0), i32 23, i8* %3)
br label %19
19: ; preds = %11, %16
%20 = add nsw i32 %6, 1
%21 = icmp eq i32 %20, 32767
br i1 %21, label %22, label %5
22: ; preds = %19
ret void
}