#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*/ printf(char *, ...);
int scanf(char *, int *);
int main() {
  int n, abs, items;
  printf("Entrer un entier: ");
  items = scanf("%d", &n);
  if (items == 1) {
    if (n < 0)
      abs = -n;
    else
      abs = n;
    printf("|%d| = %d\n", n, abs);
  } else
    printf("Erreur de lecture (pas un entier ou fin de fichier rencontrée)\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xecf(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
mov    %eax,-0x10(%rbp)
cmpl   $0x1,-0x10(%rbp)
jne    1190 <main+0x70>
cmpl   $0x0,-0x8(%rbp)
jge    1171 <main+0x51>
xor    %eax,%eax
sub    -0x8(%rbp),%eax
mov    %eax,-0xc(%rbp)
jmp    1177 <main+0x57>
mov    -0x8(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
lea    0xe92(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    119e <main+0x7e>
lea    0xe8a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xec8(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xecd(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1050 <scanf@plt>
cmp    $0x1,%eax
jne    1170 <main+0x40>
mov    0x4(%rsp),%esi
mov    %esi,%edx
neg    %edx
cmovs  %esi,%edx
lea    0xeaf(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    117c <main+0x4c>
lea    0xeaa(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [19 x i8] c"Entrer un entier: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [11 x i8] c"|%d| = %d\0A\00"
@.str.3 = [65 x i8] c"Erreur de lecture (pas un entier ou fin de fichier rencontr\C3\A9e)\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
store i32 %6, i32* %4
%7 = load i32, i32* %4
%8 = icmp eq i32 %7, 1
br i1 %8, label %9, label %21
9: ; preds = %0
%10 = load i32, i32* %2
%11 = icmp slt i32 %10, 0
br i1 %11, label %12, label %15
12: ; preds = %9
%13 = load i32, i32* %2
%14 = sub nsw i32 0, %13
store i32 %14, i32* %3
br label %17
15: ; preds = %9
%16 = load i32, i32* %2
store i32 %16, i32* %3
br label %17
17: ; preds = %15, %12
%18 = load i32, i32* %2
%19 = load i32, i32* %3
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i32 %18, i32 %19)
br label %23
21: ; preds = %0
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str.3, i64 0, i64 0))
br label %23
23: ; preds = %21, %17
ret i32 0
}

LLVM IR (-O2):
@.str = [19 x i8] c"Entrer un entier: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [11 x i8] c"|%d| = %d\0A\00"
@str = [64 x i8] c"Erreur de lecture (pas un entier ou fin de fichier rencontr\C3\A9e)\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%5 = icmp eq i32 %4, 1
br i1 %5, label %6, label %10
6: ; preds = %0
%7 = load i32, i32* %1
%8 = call i32 @llvm.abs.i32(i32 %7, i1 true)
%9 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i32 %7, i32 %8)
br label %12
10: ; preds = %0
%11 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([64 x i8], [64 x i8]* @str, i64 0, i64 0))
br label %12
12: ; preds = %10, %6
ret i32 0
}