#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 */
long INT_MAX;
long INT_MIN;
int /*<<< orphan*/ assert(int /*<<< orphan*/);
long strtol(char *, char **, int);
int check_int(char *text, int *number) {
  char *znak;
  long tmp;
  assert(text != NULL);
  assert(number != NULL);
  if (((tmp = strtol(text, &znak, 10)) >= INT_MAX) || (tmp <= INT_MIN)) {
    return 1;
  }
  if ((*text != '\0') && (*znak == '\0')) {
    *number = tmp;
    return 0;
  } else {
    return 2;
  }
}


x86 assembly (clang, -O0):
<check_int>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
cmpq   $0x0,-0x10(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
cmpq   $0x0,-0x18(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
mov    -0x10(%rbp),%rdi
lea    -0x20(%rbp),%rsi
mov    $0xa,%edx
call   1040 <strtol@plt>
mov    %rax,-0x28(%rbp)
mov    0x2e77(%rip),%rcx
cmp    (%rcx),%rax
jge    118e <check_int+0x6e>
mov    -0x28(%rbp),%rax
mov    0x2e5b(%rip),%rcx
cmp    (%rcx),%rax
jg     119a <check_int+0x7a>
movl   $0x1,-0x4(%rbp)
jmp    11d9 <check_int+0xb9>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     11d2 <check_int+0xb2>
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    11d2 <check_int+0xb2>
mov    -0x28(%rbp),%rax
mov    %eax,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
movl   $0x0,-0x4(%rbp)
jmp    11d9 <check_int+0xb9>
movl   $0x2,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<check_int>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
xor    %edi,%edi
test   %rbx,%rbx
setne  %dil
call   1030 <assert@plt>
xor    %edi,%edi
test   %r14,%r14
setne  %dil
call   1030 <assert@plt>
mov    %rsp,%rsi
mov    %rbx,%rdi
mov    $0xa,%edx
call   1040 <strtol@plt>
mov    %rax,%rcx
mov    0x2e88(%rip),%rdx
mov    $0x1,%eax
cmp    (%rdx),%rcx
jge    118e <check_int+0x6e>
mov    0x2e6f(%rip),%rdx
cmp    (%rdx),%rcx
jle    118e <check_int+0x6e>
mov    $0x2,%eax
cmpb   $0x0,(%rbx)
je     118e <check_int+0x6e>
mov    (%rsp),%rdx
cmpb   $0x0,(%rdx)
jne    118e <check_int+0x6e>
mov    %ecx,(%r14)
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@INT_MAX = global i64 0
@INT_MIN = global i64 0
define i32 @check_int(i8* %0, i32* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i32*
%6 = alloca i8*
%7 = alloca i64
store i8* %0, i8** %4
store i32* %1, i32** %5
%8 = load i8*, i8** %4
%9 = icmp ne i8* %8, null
%10 = zext i1 %9 to i32
%11 = call i32 @assert(i32 %10)
%12 = load i32*, i32** %5
%13 = icmp ne i32* %12, null
%14 = zext i1 %13 to i32
%15 = call i32 @assert(i32 %14)
%16 = load i8*, i8** %4
%17 = call i64 @strtol(i8* %16, i8** %6, i32 10)
store i64 %17, i64* %7
%18 = load i64, i64* @INT_MAX
%19 = icmp sge i64 %17, %18
br i1 %19, label %24, label %20
20: ; preds = %2
%21 = load i64, i64* %7
%22 = load i64, i64* @INT_MIN
%23 = icmp sle i64 %21, %22
br i1 %23, label %24, label %25
24: ; preds = %20, %2
store i32 1, i32* %3
br label %40
25: ; preds = %20
%26 = load i8*, i8** %4
%27 = load i8, i8* %26
%28 = sext i8 %27 to i32
%29 = icmp ne i32 %28, 0
br i1 %29, label %30, label %39
30: ; preds = %25
%31 = load i8*, i8** %6
%32 = load i8, i8* %31
%33 = sext i8 %32 to i32
%34 = icmp eq i32 %33, 0
br i1 %34, label %35, label %39
35: ; preds = %30
%36 = load i64, i64* %7
%37 = trunc i64 %36 to i32
%38 = load i32*, i32** %5
store i32 %37, i32* %38
store i32 0, i32* %3
br label %40
39: ; preds = %30, %25
store i32 2, i32* %3
br label %40
40: ; preds = %39, %35, %24
%41 = load i32, i32* %3
ret i32 %41
}

LLVM IR (-O2):
@INT_MAX = global i64 0
@INT_MIN = global i64 0
define i32 @check_int(i8* %0, i32* writeonly %1) {
%3 = alloca i8*
%4 = bitcast i8** %3 to i8*
%5 = icmp ne i8* %0, null
%6 = zext i1 %5 to i32
%7 = tail call i32 @assert(i32 %6)
%8 = icmp ne i32* %1, null
%9 = zext i1 %8 to i32
%10 = tail call i32 @assert(i32 %9)
%11 = call i64 @strtol(i8* %0, i8** %3, i32 10)
%12 = load i64, i64* @INT_MAX
%13 = icmp slt i64 %11, %12
%14 = load i64, i64* @INT_MIN
%15 = icmp sgt i64 %11, %14
%16 = select i1 %13, i1 %15, i1 false
br i1 %16, label %17, label %26
17: ; preds = %2
%18 = load i8, i8* %0
%19 = icmp eq i8 %18, 0
br i1 %19, label %26, label %20
20: ; preds = %17
%21 = load i8*, i8** %3
%22 = load i8, i8* %21
%23 = icmp eq i8 %22, 0
br i1 %23, label %24, label %26
24: ; preds = %20
%25 = trunc i64 %11 to i32
store i32 %25, i32* %1
br label %26
26: ; preds = %17, %20, %2, %24
%27 = phi i32 [ 0, %24 ], [ 1, %2 ], [ 2, %20 ], [ 2, %17 ]
ret i32 %27
}