#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*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ pause();
int /*<<< orphan*/ printf(char *);
char *rl_gets(char *);
int /*<<< orphan*/ sprintf(char *, char *, int, int);
int sscanf(char *, char *, int *, int *);
int /*<<< orphan*/ stderr;
void plus12_read(unsigned int *a, unsigned int *b) {
  int min = -(0x800);
  int max = 0x7FF;
  char prompt[1000];
  sprintf(prompt, "entrer a et b (%d<=x<=%d) > ", min, max);
  char *cmd;
  while (1) {
    cmd = rl_gets(prompt);
    if (cmd == 0) {
      printf("\n");
      printf("EOF \n");
      while (1)
        pause();
    }
    int x, y;
    if (sscanf(cmd, "%d%d", &x, &y) != 2) {
      fprintf(stderr, "missing args or bad values\n");
    } else if (x < min || max < x) {
      fprintf(stderr, "%d out of range\n", x);
    } else if (y < min || max < y) {
      fprintf(stderr, "%d out of range\n", y);
    } else {
      *a = x;
      *b = y;
      return;
    }
  }
}


x86 assembly (clang, -O0):
<plus12_read>:
push   %rbp
mov    %rsp,%rbp
sub    $0x410,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0xfffff800,-0x14(%rbp)
movl   $0x7ff,-0x18(%rbp)
lea    -0x400(%rbp),%rdi
mov    -0x14(%rbp),%edx
mov    -0x18(%rbp),%ecx
lea    0xe6b(%rip),%rsi
call   1080 <sprintf@plt>
lea    -0x400(%rbp),%rdi
call   1050 <rl_gets@plt>
mov    %rax,-0x408(%rbp)
cmpq   $0x0,-0x408(%rbp)
jne    11df <plus12_read+0x7f>
lea    0xe5f(%rip),%rdi
call   1030 <printf@plt>
lea    0xe4f(%rip),%rdi
call   1030 <printf@plt>
mov    $0x0,%al
call   1060 <pause@plt>
jmp    11d3 <plus12_read+0x73>
mov    -0x408(%rbp),%rdi
lea    0xe36(%rip),%rsi
lea    -0x40c(%rbp),%rdx
lea    -0x410(%rbp),%rcx
call   1070 <sscanf@plt>
cmp    $0x2,%eax
je     1225 <plus12_read+0xc5>
mov    0x2dd0(%rip),%rax
mov    (%rax),%edi
lea    0xe0f(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
jmp    12d0 <plus12_read+0x170>
mov    -0x40c(%rbp),%eax
cmp    -0x14(%rbp),%eax
jl     1243 <plus12_read+0xe3>
mov    -0x18(%rbp),%eax
cmp    -0x40c(%rbp),%eax
jge    1265 <plus12_read+0x105>
mov    0x2d96(%rip),%rax
mov    (%rax),%edi
mov    -0x40c(%rbp),%edx
lea    0xdeb(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
jmp    12cb <plus12_read+0x16b>
mov    -0x410(%rbp),%eax
cmp    -0x14(%rbp),%eax
jl     1283 <plus12_read+0x123>
mov    -0x18(%rbp),%eax
cmp    -0x410(%rbp),%eax
jge    12a5 <plus12_read+0x145>
mov    0x2d56(%rip),%rax
mov    (%rax),%edi
mov    -0x410(%rbp),%edx
lea    0xdab(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
jmp    12c6 <plus12_read+0x166>
mov    -0x40c(%rbp),%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x410(%rbp),%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
add    $0x410,%rsp
pop    %rbp
ret
jmp    12cb <plus12_read+0x16b>
jmp    12d0 <plus12_read+0x170>
jmp    119a <plus12_read+0x3a>

x86 assembly (clang, -O2):
<plus12_read>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x408,%rsp
mov    %rsi,0x18(%rsp)
mov    %rdi,0x10(%rsp)
lea    0xe6e(%rip),%rsi
lea    0x20(%rsp),%rbx
mov    %rbx,%rdi
mov    $0xfffff800,%edx
mov    $0x7ff,%ecx
call   1090 <sprintf@plt>
mov    %rbx,%rdi
call   1060 <rl_gets@plt>
test   %rax,%rax
je     1257 <plus12_read+0xe7>
lea    0xe5c(%rip),%r12
lea    0xc(%rsp),%r13
lea    0x8(%rsp),%rbx
mov    0x2e0e(%rip),%rbp
lea    0x20(%rsp),%r14
lea    0xe44(%rip),%r15
jmp    11fa <plus12_read+0x8a>
mov    0x0(%rbp),%edi
mov    %r15,%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    %r14,%rdi
call   1060 <rl_gets@plt>
test   %rax,%rax
je     1257 <plus12_read+0xe7>
mov    %rax,%rdi
mov    %r12,%rsi
mov    %r13,%rdx
mov    %rbx,%rcx
call   1080 <sscanf@plt>
cmp    $0x2,%eax
jne    11e0 <plus12_read+0x70>
mov    0xc(%rsp),%edx
lea    -0x800(%rdx),%eax
cmp    $0xffffefff,%eax
ja     1230 <plus12_read+0xc0>
mov    0x0(%rbp),%edi
lea    0xe13(%rip),%rsi
jmp    124e <plus12_read+0xde>
nopl   (%rax)
mov    0x8(%rsp),%eax
lea    -0x800(%rax),%ecx
cmp    $0xffffefff,%ecx
ja     1279 <plus12_read+0x109>
mov    0x0(%rbp),%edi
lea    0xdf2(%rip),%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1050 <fprintf@plt>
jmp    11ed <plus12_read+0x7d>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xde7(%rip),%rdi
call   1040 <puts@plt>
nopl   (%rax)
xor    %eax,%eax
call   1070 <pause@plt>
jmp    1270 <plus12_read+0x100>
mov    0x10(%rsp),%rcx
mov    %edx,(%rcx)
mov    0x18(%rsp),%rcx
mov    %eax,(%rcx)
add    $0x408,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [29 x i8] c"entrer a et b (%d<=x<=%d) > \00"
@.str.1 = [2 x i8] c"\0A\00"
@.str.2 = [6 x i8] c"EOF \0A\00"
@.str.3 = [5 x i8] c"%d%d\00"
@stderr = global i32 0
@.str.4 = [28 x i8] c"missing args or bad values\0A\00"
@.str.5 = [17 x i8] c"%d out of range\0A\00"
define void @plus12_read(i32* %0, i32* %1) {
%3 = alloca i32*
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i32
%7 = alloca [1000 x i8]
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i32
store i32* %0, i32** %3
store i32* %1, i32** %4
store i32 -2048, i32* %5
store i32 2047, i32* %6
%11 = getelementptr inbounds [1000 x i8], [1000 x i8]* %7, i64 0, i64 0
%12 = load i32, i32* %5
%13 = load i32, i32* %6
%14 = call i32 @sprintf(i8* %11, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i32 %12, i32 %13)
br label %15
15: ; preds = %2, %63
%16 = getelementptr inbounds [1000 x i8], [1000 x i8]* %7, i64 0, i64 0
%17 = call i8* @rl_gets(i8* %16)
store i8* %17, i8** %8
%18 = load i8*, i8** %8
%19 = icmp eq i8* %18, null
br i1 %19, label %20, label %25
20: ; preds = %15
%21 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%22 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
br label %23
23: ; preds = %20, %23
%24 = call i32 (...) @pause()
br label %23
25: ; preds = %15
%26 = load i8*, i8** %8
%27 = call i32 @sscanf(i8* %26, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32* %9, i32* %10)
%28 = icmp ne i32 %27, 2
br i1 %28, label %29, label %32
29: ; preds = %25
%30 = load i32, i32* @stderr
%31 = call i32 (i32, i8*, ...) @fprintf(i32 %30, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.4, i64 0, i64 0))
br label %63
32: ; preds = %25
%33 = load i32, i32* %9
%34 = load i32, i32* %5
%35 = icmp slt i32 %33, %34
br i1 %35, label %40, label %36
36: ; preds = %32
%37 = load i32, i32* %6
%38 = load i32, i32* %9
%39 = icmp slt i32 %37, %38
br i1 %39, label %40, label %44
40: ; preds = %36, %32
%41 = load i32, i32* @stderr
%42 = load i32, i32* %9
%43 = call i32 (i32, i8*, ...) @fprintf(i32 %41, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i64 0, i64 0), i32 %42)
br label %62
44: ; preds = %36
%45 = load i32, i32* %10
%46 = load i32, i32* %5
%47 = icmp slt i32 %45, %46
br i1 %47, label %52, label %48
48: ; preds = %44
%49 = load i32, i32* %6
%50 = load i32, i32* %10
%51 = icmp slt i32 %49, %50
br i1 %51, label %52, label %56
52: ; preds = %48, %44
%53 = load i32, i32* @stderr
%54 = load i32, i32* %10
%55 = call i32 (i32, i8*, ...) @fprintf(i32 %53, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i64 0, i64 0), i32 %54)
br label %61
56: ; preds = %48
%57 = load i32, i32* %9
%58 = load i32*, i32** %3
store i32 %57, i32* %58
%59 = load i32, i32* %10
%60 = load i32*, i32** %4
store i32 %59, i32* %60
ret void
61: ; preds = %52
br label %62
62: ; preds = %61, %40
br label %63
63: ; preds = %62, %29
br label %15
}

LLVM IR (-O2):
@.str = [29 x i8] c"entrer a et b (%d<=x<=%d) > \00"
@.str.3 = [5 x i8] c"%d%d\00"
@stderr = global i32 0
@.str.4 = [28 x i8] c"missing args or bad values\0A\00"
@.str.5 = [17 x i8] c"%d out of range\0A\00"
@str = [5 x i8] c"EOF \00"
define void @plus12_read(i32* nocapture writeonly %0, i32* nocapture writeonly %1) {
%3 = alloca [1000 x i8]
%4 = alloca i32
%5 = alloca i32
%6 = getelementptr inbounds [1000 x i8], [1000 x i8]* %3, i64 0, i64 0
%7 = call i32 @sprintf(i8* %6, i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i32 -2048, i32 2047)
%8 = call i8* @rl_gets(i8* %6)
%9 = icmp eq i8* %8, null
br i1 %9, label %13, label %10
10: ; preds = %2
%11 = bitcast i32* %4 to i8*
%12 = bitcast i32* %5 to i8*
br label %18
13: ; preds = %40, %2
%14 = call i32 @putchar(i32 10)
%15 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @str, i64 0, i64 0))
br label %16
16: ; preds = %16, %13
%17 = call i32 (...) @pause()
br label %16
18: ; preds = %10, %40
%19 = phi i8* [ %8, %10 ], [ %41, %40 ]
%20 = call i32 @sscanf(i8* %19, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32* %4, i32* %5)
%21 = icmp eq i32 %20, 2
br i1 %21, label %25, label %22
22: ; preds = %18
%23 = load i32, i32* @stderr
%24 = call i32 (i32, i8*, ...) @fprintf(i32 %23, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.4, i64 0, i64 0))
br label %40
25: ; preds = %18
%26 = load i32, i32* %4
%27 = add i32 %26, -2048
%28 = icmp ult i32 %27, -4096
br i1 %28, label %29, label %32
29: ; preds = %25
%30 = load i32, i32* @stderr
%31 = call i32 (i32, i8*, ...) @fprintf(i32 %30, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i64 0, i64 0), i32 %26)
br label %40
32: ; preds = %25
%33 = load i32, i32* %5
%34 = add i32 %33, -2048
%35 = icmp ult i32 %34, -4096
br i1 %35, label %36, label %39
36: ; preds = %32
%37 = load i32, i32* @stderr
%38 = call i32 (i32, i8*, ...) @fprintf(i32 %37, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i64 0, i64 0), i32 %33)
br label %40
39: ; preds = %32
store i32 %26, i32* %0
store i32 %33, i32* %1
ret void
40: ; preds = %22, %36, %29
%41 = call i8* @rl_gets(i8* %6)
%42 = icmp eq i8* %41, null
br i1 %42, label %13, label %18
}