#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int __scan_uint(int /*<<< orphan*/ *, int, int);
char getc(int /*<<< orphan*/ *);
int /*<<< orphan*/ ungetc(char, int /*<<< orphan*/ *);
int __scan_int(FILE *stream, int width, int flags) {
  char c;
  c = getc(stream);
  if (c == '-') {
    return -__scan_uint(stream, width - 1, flags);
  } else {
    ungetc(c, stream);
    return __scan_uint(stream, width - 1, flags);
  }
}


x86 assembly (clang, -O0):
<__scan_int>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %edx,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <getc@plt>
mov    %al,-0x19(%rbp)
movsbl -0x19(%rbp),%eax
cmp    $0x2d,%eax
jne    117b <__scan_int+0x4b>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
sub    $0x1,%esi
mov    -0x18(%rbp),%edx
call   1030 <__scan_uint@plt>
mov    %eax,%ecx
xor    %eax,%eax
sub    %ecx,%eax
mov    %eax,-0x4(%rbp)
jmp    119f <__scan_int+0x6f>
mov    -0x19(%rbp),%al
mov    -0x10(%rbp),%rsi
movsbl %al,%edi
call   1040 <ungetc@plt>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
sub    $0x1,%esi
mov    -0x18(%rbp),%edx
call   1030 <__scan_uint@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<__scan_int>:
push   %rbp
push   %r14
push   %rbx
mov    %edx,%r14d
mov    %esi,%ebp
mov    %rdi,%rbx
call   1050 <getc@plt>
cmp    $0x2d,%al
jne    115c <__scan_int+0x2c>
add    $0xffffffff,%ebp
mov    %rbx,%rdi
mov    %ebp,%esi
mov    %r14d,%edx
call   1030 <__scan_uint@plt>
neg    %eax
pop    %rbx
pop    %r14
pop    %rbp
ret
movsbl %al,%edi
mov    %rbx,%rsi
call   1040 <ungetc@plt>
add    $0xffffffff,%ebp
mov    %rbx,%rdi
mov    %ebp,%esi
mov    %r14d,%edx
pop    %rbx
pop    %r14
pop    %rbp
jmp    1030 <__scan_uint@plt>

LLVM IR (-O0):
define i32 @__scan_int(i32* %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8
store i32* %0, i32** %5
store i32 %1, i32* %6
store i32 %2, i32* %7
%9 = load i32*, i32** %5
%10 = call signext i8 @getc(i32* %9)
store i8 %10, i8* %8
%11 = load i8, i8* %8
%12 = sext i8 %11 to i32
%13 = icmp eq i32 %12, 45
br i1 %13, label %14, label %21
14: ; preds = %3
%15 = load i32*, i32** %5
%16 = load i32, i32* %6
%17 = sub nsw i32 %16, 1
%18 = load i32, i32* %7
%19 = call i32 @__scan_uint(i32* %15, i32 %17, i32 %18)
%20 = sub nsw i32 0, %19
store i32 %20, i32* %4
br label %30
21: ; preds = %3
%22 = load i8, i8* %8
%23 = load i32*, i32** %5
%24 = call i32 @ungetc(i8 signext %22, i32* %23)
%25 = load i32*, i32** %5
%26 = load i32, i32* %6
%27 = sub nsw i32 %26, 1
%28 = load i32, i32* %7
%29 = call i32 @__scan_uint(i32* %25, i32 %27, i32 %28)
store i32 %29, i32* %4
br label %30
30: ; preds = %21, %14
%31 = load i32, i32* %4
ret i32 %31
}

LLVM IR (-O2):
define i32 @__scan_int(i32* %0, i32 %1, i32 %2) {
%4 = tail call signext i8 @getc(i32* %0)
%5 = icmp eq i8 %4, 45
br i1 %5, label %6, label %10
6: ; preds = %3
%7 = add nsw i32 %1, -1
%8 = tail call i32 @__scan_uint(i32* %0, i32 %7, i32 %2)
%9 = sub nsw i32 0, %8
br label %14
10: ; preds = %3
%11 = tail call i32 @ungetc(i8 signext %4, i32* %0)
%12 = add nsw i32 %1, -1
%13 = tail call i32 @__scan_uint(i32* %0, i32 %12, i32 %2)
br label %14
14: ; preds = %10, %6
%15 = phi i32 [ %9, %6 ], [ %13, %10 ]
ret i32 %15
}