#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*/ exit(int);
int /*<<< orphan*/ printf(char *, ...);
int scanf(char *, int *);
int /*<<< orphan*/ skiptonl(int /*<<< orphan*/);
scalar_t__ testnl();
scalar_t__ testterm();
int getintpar(const char *s) {
  int i;
  int n;
  while (1) {
    if (testnl() && s)
      printf("%s: ", s);
    i = scanf("%d", &n);
    if (i < 0)
      exit(1);
    if (i > 0 && testterm())
      return (n);
    printf("invalid input; please enter an integer\n");
    skiptonl(0);
  }
}


x86 assembly (clang, -O0):
<getintpar>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    $0x0,%al
call   1080 <testnl@plt>
cmp    $0x0,%rax
je     119a <getintpar+0x3a>
cmpq   $0x0,-0x8(%rbp)
je     119a <getintpar+0x3a>
mov    -0x8(%rbp),%rsi
lea    0xe6d(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xe64(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1060 <scanf@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jge    11c1 <getintpar+0x61>
mov    $0x1,%edi
call   1070 <exit@plt>
cmpl   $0x0,-0xc(%rbp)
jle    11e5 <getintpar+0x85>
mov    $0x0,%al
call   1030 <testterm@plt>
cmp    $0x0,%rax
je     11e5 <getintpar+0x85>
mov    -0x10(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret
lea    0xe1c(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
xor    %edi,%edi
call   1040 <skiptonl@plt>
jmp    116c <getintpar+0xc>

x86 assembly (clang, -O2):
<getintpar>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rbx
lea    0xe79(%rip),%r14
lea    0xe77(%rip),%r15
lea    0xc(%rsp),%r12
lea    0xe6e(%rip),%r13
jmp    11af <getintpar+0x3f>
nopl   0x0(%rax)
mov    %r13,%rdi
call   1040 <puts@plt>
xor    %edi,%edi
call   1050 <skiptonl@plt>
xor    %eax,%eax
call   1090 <testnl@plt>
test   %rbx,%rbx
je     11cd <getintpar+0x5d>
test   %rax,%rax
je     11cd <getintpar+0x5d>
mov    %r14,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %r15,%rdi
mov    %r12,%rsi
call   1070 <scanf@plt>
test   %eax,%eax
js     11fc <getintpar+0x8c>
je     11a0 <getintpar+0x30>
xor    %eax,%eax
call   1030 <testterm@plt>
test   %rax,%rax
je     11a0 <getintpar+0x30>
mov    0xc(%rsp),%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret
mov    $0x1,%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@.str = [5 x i8] c"%s: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [40 x i8] c"invalid input; please enter an integer\0A\00"
define i32 @getintpar(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i32
store i8* %0, i8** %2
br label %5
5: ; preds = %1, %28
%6 = call i64 (...) @testnl()
%7 = icmp ne i64 %6, 0
br i1 %7, label %8, label %14
8: ; preds = %5
%9 = load i8*, i8** %2
%10 = icmp ne i8* %9, null
br i1 %10, label %11, label %14
11: ; preds = %8
%12 = load i8*, i8** %2
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %12)
br label %14
14: ; preds = %11, %8, %5
%15 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %4)
store i32 %15, i32* %3
%16 = load i32, i32* %3
%17 = icmp slt i32 %16, 0
br i1 %17, label %18, label %20
18: ; preds = %14
%19 = call i32 @exit(i32 1)
unreachable
20: ; preds = %14
%21 = load i32, i32* %3
%22 = icmp sgt i32 %21, 0
br i1 %22, label %23, label %28
23: ; preds = %20
%24 = call i64 (...) @testterm()
%25 = icmp ne i64 %24, 0
br i1 %25, label %26, label %28
26: ; preds = %23
%27 = load i32, i32* %4
ret i32 %27
28: ; preds = %23, %20
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.2, i64 0, i64 0))
%30 = call i32 @skiptonl(i32 0)
br label %5
}

LLVM IR (-O2):
@.str = [5 x i8] c"%s: \00"
@.str.1 = [3 x i8] c"%d\00"
@str = [39 x i8] c"invalid input; please enter an integer\00"
define i32 @getintpar(i8* %0) {
%2 = alloca i32
%3 = bitcast i32* %2 to i8*
%4 = icmp ne i8* %0, null
br label %5
5: ; preds = %23, %1
%6 = call i64 (...) @testnl()
%7 = icmp ne i64 %6, 0
%8 = and i1 %4, %7
br i1 %8, label %9, label %11
9: ; preds = %5
%10 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %0)
br label %11
11: ; preds = %9, %5
%12 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%13 = icmp slt i32 %12, 0
br i1 %13, label %14, label %16
14: ; preds = %11
%15 = call i32 @exit(i32 1)
unreachable
16: ; preds = %11
%17 = icmp eq i32 %12, 0
br i1 %17, label %23, label %18
18: ; preds = %16
%19 = call i64 (...) @testterm()
%20 = icmp eq i64 %19, 0
br i1 %20, label %23, label %21
21: ; preds = %18
%22 = load i32, i32* %2
ret i32 %22
23: ; preds = %18, %16
%24 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @str, i64 0, i64 0))
%25 = call i32 @skiptonl(i32 0)
br label %5
}