#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 read_int(int *);
int read_ID(int *id_ptr) {
  int ret = read_int(id_ptr);
  if (ret != 0) {
    printf("read invalid id format\n");
    return -1;
  }
  int id = *id_ptr;
  if (id < 100000 || 999999 < id) {
    printf("id out of range %d\n", id);
    return -2;
  }
  return 0;
}


x86 assembly (clang, -O0):
<read_ID>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <read_int@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
je     115c <read_ID+0x3c>
lea    0xeb7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11a4 <read_ID+0x84>
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x18(%rbp)
cmpl   $0x186a0,-0x18(%rbp)
jl     1180 <read_ID+0x60>
mov    $0xf423f,%eax
cmp    -0x18(%rbp),%eax
jge    119d <read_ID+0x7d>
mov    -0x18(%rbp),%esi
lea    0xe8e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0xfffffffe,-0x4(%rbp)
jmp    11a4 <read_ID+0x84>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_ID>:
push   %rbx
mov    %rdi,%rbx
call   1050 <read_int@plt>
test   %eax,%eax
je     1150 <read_ID+0x20>
lea    0xed0(%rip),%rdi
call   1030 <puts@plt>
mov    $0xffffffff,%eax
pop    %rbx
ret
mov    (%rbx),%esi
lea    -0xf4240(%rsi),%ecx
xor    %eax,%eax
cmp    $0xfff2445f,%ecx
ja     1175 <read_ID+0x45>
lea    0xe97(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0xfffffffe,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [24 x i8] c"read invalid id format\0A\00"
@.str.1 = [20 x i8] c"id out of range %d\0A\00"
define i32 @read_ID(i32* %0) {
%2 = alloca i32
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i32
store i32* %0, i32** %3
%6 = load i32*, i32** %3
%7 = call i32 @read_int(i32* %6)
store i32 %7, i32* %4
%8 = load i32, i32* %4
%9 = icmp ne i32 %8, 0
br i1 %9, label %10, label %12
10: ; preds = %1
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %2
br label %24
12: ; preds = %1
%13 = load i32*, i32** %3
%14 = load i32, i32* %13
store i32 %14, i32* %5
%15 = load i32, i32* %5
%16 = icmp slt i32 %15, 100000
br i1 %16, label %20, label %17
17: ; preds = %12
%18 = load i32, i32* %5
%19 = icmp slt i32 999999, %18
br i1 %19, label %20, label %23
20: ; preds = %17, %12
%21 = load i32, i32* %5
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i32 %21)
store i32 -2, i32* %2
br label %24
23: ; preds = %17
store i32 0, i32* %2
br label %24
24: ; preds = %23, %20, %10
%25 = load i32, i32* %2
ret i32 %25
}

LLVM IR (-O2):
@.str.1 = [20 x i8] c"id out of range %d\0A\00"
@str = [23 x i8] c"read invalid id format\00"
define i32 @read_ID(i32* %0) {
%2 = tail call i32 @read_int(i32* %0)
%3 = icmp eq i32 %2, 0
br i1 %3, label %6, label %4
4: ; preds = %1
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str, i64 0, i64 0))
br label %12
6: ; preds = %1
%7 = load i32, i32* %0
%8 = add i32 %7, -1000000
%9 = icmp ult i32 %8, -900000
br i1 %9, label %10, label %12
10: ; preds = %6
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i32 %7)
br label %12
12: ; preds = %10, %6, %4
%13 = phi i32 [ -1, %4 ], [ -2, %10 ], [ 0, %6 ]
ret i32 %13
}