#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*/ saisie_chaine(char *, int);
long strtol(char *, char **, int);
int saisie_int(int *pn) {
  long int n;
  static char buffer[256];
  char c, *p;
  p = &c;
  c = 'A';
  saisie_chaine(buffer, 256);
  n = strtol(buffer, &p, 10);
  if (*p == '\0') {
    *pn = (int)n;
    return 1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<saisie_int>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
lea    -0x19(%rbp),%rax
mov    %rax,-0x28(%rbp)
movb   $0x41,-0x19(%rbp)
lea    0x2f01(%rip),%rdi
mov    $0x100,%esi
call   1040 <saisie_chaine@plt>
lea    0x2ef0(%rip),%rdi
lea    -0x28(%rbp),%rsi
mov    $0xa,%edx
call   1030 <strtol@plt>
mov    %rax,-0x18(%rbp)
mov    -0x28(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    118a <saisie_int+0x6a>
mov    -0x18(%rbp),%rax
mov    %eax,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
movl   $0x1,-0x4(%rbp)
jmp    1191 <saisie_int+0x71>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<saisie_int>:
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %rdi,%r14
lea    0xf(%rsp),%rax
mov    %rax,0x10(%rsp)
movb   $0x41,0xf(%rsp)
lea    0x2f00(%rip),%rbx
mov    %rbx,%rdi
mov    $0x100,%esi
call   1040 <saisie_chaine@plt>
lea    0x10(%rsp),%rsi
mov    %rbx,%rdi
mov    $0xa,%edx
call   1030 <strtol@plt>
mov    0x10(%rsp),%rdx
xor    %ecx,%ecx
cmpb   $0x0,(%rdx)
jne    1173 <saisie_int+0x53>
mov    %eax,(%r14)
mov    $0x1,%ecx
mov    %ecx,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@saisie_int.buffer = internal global [256 x i8] zeroinitializer
define i32 @saisie_int(i32* %0) {
%2 = alloca i32
%3 = alloca i32*
%4 = alloca i64
%5 = alloca i8
%6 = alloca i8*
store i32* %0, i32** %3
store i8* %5, i8** %6
store i8 65, i8* %5
%7 = call i32 @saisie_chaine(i8* getelementptr inbounds ([256 x i8], [256 x i8]* @saisie_int.buffer, i64 0, i64 0), i32 256)
%8 = call i64 @strtol(i8* getelementptr inbounds ([256 x i8], [256 x i8]* @saisie_int.buffer, i64 0, i64 0), i8** %6, i32 10)
store i64 %8, i64* %4
%9 = load i8*, i8** %6
%10 = load i8, i8* %9
%11 = sext i8 %10 to i32
%12 = icmp eq i32 %11, 0
br i1 %12, label %13, label %17
13: ; preds = %1
%14 = load i64, i64* %4
%15 = trunc i64 %14 to i32
%16 = load i32*, i32** %3
store i32 %15, i32* %16
store i32 1, i32* %2
br label %18
17: ; preds = %1
store i32 0, i32* %2
br label %18
18: ; preds = %17, %13
%19 = load i32, i32* %2
ret i32 %19
}

LLVM IR (-O2):
@saisie_int.buffer = internal global [256 x i8] zeroinitializer
define i32 @saisie_int(i32* nocapture writeonly %0) {
%2 = alloca i8
%3 = alloca i8*
%4 = bitcast i8** %3 to i8*
store i8* %2, i8** %3
store i8 65, i8* %2
%5 = call i32 @saisie_chaine(i8* getelementptr inbounds ([256 x i8], [256 x i8]* @saisie_int.buffer, i64 0, i64 0), i32 256)
%6 = call i64 @strtol(i8* getelementptr inbounds ([256 x i8], [256 x i8]* @saisie_int.buffer, i64 0, i64 0), i8** %3, i32 10)
%7 = load i8*, i8** %3
%8 = load i8, i8* %7
%9 = icmp eq i8 %8, 0
br i1 %9, label %10, label %12
10: ; preds = %1
%11 = trunc i64 %6 to i32
store i32 %11, i32* %0
br label %12
12: ; preds = %1, %10
%13 = phi i32 [ 1, %10 ], [ 0, %1 ]
ret i32 %13
}