#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 modp_init(char *, int, int /*<<< orphan*/);
int modp_run();
int read_stdin(char **);
int main() {
  char *buf;
  int len = read_stdin(&buf);
  if (len < 0) {
    return -1;
  }
  int ret = modp_init(buf, len, 0);
  if (ret >= 0) {
    do {
      ret = modp_run();
    } while (ret > 0);
  }
  return ret;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x10(%rbp),%rdi
call   1030 <read_stdin@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jge    1161 <main+0x31>
movl   $0xffffffff,-0x4(%rbp)
jmp    11a0 <main+0x70>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
xor    %edx,%edx
call   1050 <modp_init@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jl     119a <main+0x6a>
jmp    1181 <main+0x51>
mov    $0x0,%al
call   1040 <modp_run@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jg     1181 <main+0x51>
jmp    119a <main+0x6a>
mov    -0x18(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
mov    %rsp,%rdi
call   1030 <read_stdin@plt>
test   %eax,%eax
js     115d <main+0x2d>
mov    (%rsp),%rdi
mov    %eax,%esi
xor    %edx,%edx
call   1050 <modp_init@plt>
test   %eax,%eax
js     115b <main+0x2b>
xchg   %ax,%ax
xor    %eax,%eax
call   1040 <modp_run@plt>
test   %eax,%eax
jg     1150 <main+0x20>
pop    %rcx
ret
mov    $0xffffffff,%eax
pop    %rcx
ret

LLVM IR (-O0):
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
%5 = call i32 @read_stdin(i8** %2)
store i32 %5, i32* %3
%6 = load i32, i32* %3
%7 = icmp slt i32 %6, 0
br i1 %7, label %8, label %9
8: ; preds = %0
store i32 -1, i32* %1
br label %24
9: ; preds = %0
%10 = load i8*, i8** %2
%11 = load i32, i32* %3
%12 = call i32 @modp_init(i8* %10, i32 %11, i32 0)
store i32 %12, i32* %4
%13 = load i32, i32* %4
%14 = icmp sge i32 %13, 0
br i1 %14, label %15, label %22
15: ; preds = %9
br label %16
16: ; preds = %18, %15
%17 = call i32 (...) @modp_run()
store i32 %17, i32* %4
br label %18
18: ; preds = %16
%19 = load i32, i32* %4
%20 = icmp sgt i32 %19, 0
br i1 %20, label %16, label %21
21: ; preds = %18
br label %22
22: ; preds = %21, %9
%23 = load i32, i32* %4
store i32 %23, i32* %1
br label %24
24: ; preds = %22, %8
%25 = load i32, i32* %1
ret i32 %25
}

LLVM IR (-O2):
define i32 @main() {
%1 = alloca i8*
%2 = bitcast i8** %1 to i8*
%3 = call i32 @read_stdin(i8** %1)
%4 = icmp slt i32 %3, 0
br i1 %4, label %12, label %5
5: ; preds = %0
%6 = load i8*, i8** %1
%7 = call i32 @modp_init(i8* %6, i32 %3, i32 0)
%8 = icmp sgt i32 %7, -1
br i1 %8, label %9, label %12
9: ; preds = %5, %9
%10 = call i32 (...) @modp_run()
%11 = icmp sgt i32 %10, 0
br i1 %11, label %9, label %12
12: ; preds = %9, %5, %0
%13 = phi i32 [ -1, %0 ], [ %7, %5 ], [ %10, %9 ]
ret i32 %13
}