int getintpar(s) 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,%eax
je     1199 <getintpar+0x39>
cmpq   $0x0,-0x8(%rbp)
je     1199 <getintpar+0x39>
mov    -0x8(%rbp),%rsi
lea    0xe6e(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xe65(%rip),%rdi
lea    -0x10(%rbp),%rsi
mov    $0x0,%al
call   1060 <scanf@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jge    11c2 <getintpar+0x62>
mov    $0x1,%edi
call   1070 <exit@plt>
cmpl   $0x0,-0xc(%rbp)
jle    11e5 <getintpar+0x85>
mov    $0x0,%al
call   1030 <testterm@plt>
cmp    $0x0,%eax
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
mov    $0x0,%al
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    11b1 <getintpar+0x41>
nopl   0x0(%rax)
mov    %r13,%rdi
call   1040 <puts@plt>
xor    %edi,%edi
xor    %eax,%eax
call   1050 <skiptonl@plt>
xor    %eax,%eax
call   1090 <testnl@plt>
test   %rbx,%rbx
je     11ce <getintpar+0x5e>
test   %eax,%eax
je     11ce <getintpar+0x5e>
mov    %r14,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %r15,%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1070 <scanf@plt>
test   %eax,%eax
js     11fe <getintpar+0x8e>
je     11a0 <getintpar+0x30>
xor    %eax,%eax
call   1030 <testterm@plt>
test   %eax,%eax
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, %27
%6 = call i32 (...) @testnl()
%7 = icmp ne i32 %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 (i8*, ...) @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 %19
18: ; preds = %14
unreachable
19: ; preds = %14
%20 = load i32, i32* %3
%21 = icmp sgt i32 %20, 0
br i1 %21, label %22, label %27
22: ; preds = %19
%23 = call i32 (...) @testterm()
%24 = icmp ne i32 %23, 0
br i1 %24, label %25, label %27
25: ; preds = %22
%26 = load i32, i32* %4
ret i32 %26
27: ; preds = %22, %19
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.2, i64 0, i64 0))
%29 = call i32 (i32, ...) bitcast (i32 (...)* @skiptonl to i32 (i32, ...)*)(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 = %22, %1
%6 = call i32 (...) @testnl()
%7 = icmp ne i32 %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 (i8*, ...) @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 %15
14: ; preds = %11
unreachable
15: ; preds = %11
%16 = icmp eq i32 %12, 0
br i1 %16, label %22, label %17
17: ; preds = %15
%18 = call i32 (...) @testterm()
%19 = icmp eq i32 %18, 0
br i1 %19, label %22, label %20
20: ; preds = %17
%21 = load i32, i32* %2
ret i32 %21
22: ; preds = %17, %15
%23 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @str, i64 0, i64 0))
%24 = call i32 (i32, ...) bitcast (i32 (...)* @skiptonl to i32 (i32, ...)*)(i32 0)
br label %5
}