#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 */
typedef int /*<<< orphan*/ mpz_t;

/* Variables and functions */
int /*<<< orphan*/ free(char *);
int mpz_set_str(int /*<<< orphan*/, char *, int);
int /*<<< orphan*/ mpz_set_ui(int /*<<< orphan*/, int /*<<< orphan*/);
char *strdup(char *);
int strlen(char *);
int /*<<< orphan*/ strspn(char *, char *);
int string2mpz(mpz_t rop, char *x, int base) {
  size_t l;
  char *y;
  int rv;
  x += strspn(x, " \t+");
  if (strlen(x) == 0)
    mpz_set_ui(rop, 0);
  y = strdup(x);
  for (l = strlen(y) - 1; y[l] == '\n'; l--) {
    y[l] = '\0';
    if (l == 0)
      break;
  }
  rv = mpz_set_str(rop, y, base);
  free(y);
  return rv;
}


x86 assembly (clang, -O0):
<string2mpz>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe83(%rip),%rsi
call   1050 <strspn@plt>
mov    %eax,%ecx
mov    -0x10(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
cmp    $0x0,%eax
jne    11ae <string2mpz+0x4e>
mov    -0x4(%rbp),%edi
xor    %esi,%esi
call   1070 <mpz_set_ui@plt>
mov    -0x10(%rbp),%rdi
call   1080 <strdup@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
call   1040 <strlen@plt>
sub    $0x1,%eax
cltq
mov    %rax,-0x20(%rbp)
mov    -0x28(%rbp),%rax
mov    -0x20(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0xa,%eax
jne    1214 <string2mpz+0xb4>
mov    -0x28(%rbp),%rax
mov    -0x20(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
cmpq   $0x0,-0x20(%rbp)
jne    11fe <string2mpz+0x9e>
jmp    1214 <string2mpz+0xb4>
jmp    1203 <string2mpz+0xa3>
mov    -0x20(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x20(%rbp)
jmp    11cd <string2mpz+0x6d>
mov    -0x4(%rbp),%edi
mov    -0x28(%rbp),%rsi
mov    -0x14(%rbp),%edx
call   1060 <mpz_set_str@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
mov    -0x2c(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<string2mpz>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edx,%r14d
mov    %rsi,%rbp
mov    %edi,%r15d
lea    0xe89(%rip),%rsi
mov    %rbp,%rdi
call   1050 <strspn@plt>
movslq %eax,%rbx
add    %rbp,%rbx
mov    %rbx,%rdi
call   1040 <strlen@plt>
test   %eax,%eax
jne    119b <string2mpz+0x3b>
mov    %r15d,%edi
xor    %esi,%esi
call   1070 <mpz_set_ui@plt>
mov    %rbx,%rdi
call   1080 <strdup@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1040 <strlen@plt>
cltq
cmpb   $0xa,-0x1(%rbx,%rax,1)
jne    11d4 <string2mpz+0x74>
add    $0xffffffffffffffff,%rax
mov    %rax,%rcx
xchg   %ax,%ax
movb   $0x0,(%rbx,%rax,1)
sub    $0x1,%rcx
jb     11d4 <string2mpz+0x74>
cmpb   $0xa,-0x1(%rbx,%rax,1)
mov    %rcx,%rax
je     11c0 <string2mpz+0x60>
mov    %r15d,%edi
mov    %rbx,%rsi
mov    %r14d,%edx
call   1060 <mpz_set_str@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c" \09+\00"
define i32 @string2mpz(i32 %0, i8* %1, i32 %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i64
%8 = alloca i8*
%9 = alloca i32
store i32 %0, i32* %4
store i8* %1, i8** %5
store i32 %2, i32* %6
%10 = load i8*, i8** %5
%11 = call i32 @strspn(i8* %10, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%12 = load i8*, i8** %5
%13 = sext i32 %11 to i64
%14 = getelementptr inbounds i8, i8* %12, i64 %13
store i8* %14, i8** %5
%15 = load i8*, i8** %5
%16 = call i32 @strlen(i8* %15)
%17 = icmp eq i32 %16, 0
br i1 %17, label %18, label %21
18: ; preds = %3
%19 = load i32, i32* %4
%20 = call i32 @mpz_set_ui(i32 %19, i32 0)
br label %21
21: ; preds = %18, %3
%22 = load i8*, i8** %5
%23 = call i8* @strdup(i8* %22)
store i8* %23, i8** %8
%24 = load i8*, i8** %8
%25 = call i32 @strlen(i8* %24)
%26 = sub nsw i32 %25, 1
%27 = sext i32 %26 to i64
store i64 %27, i64* %7
br label %28
28: ; preds = %43, %21
%29 = load i8*, i8** %8
%30 = load i64, i64* %7
%31 = getelementptr inbounds i8, i8* %29, i64 %30
%32 = load i8, i8* %31
%33 = sext i8 %32 to i32
%34 = icmp eq i32 %33, 10
br i1 %34, label %35, label %46
35: ; preds = %28
%36 = load i8*, i8** %8
%37 = load i64, i64* %7
%38 = getelementptr inbounds i8, i8* %36, i64 %37
store i8 0, i8* %38
%39 = load i64, i64* %7
%40 = icmp eq i64 %39, 0
br i1 %40, label %41, label %42
41: ; preds = %35
br label %46
42: ; preds = %35
br label %43
43: ; preds = %42
%44 = load i64, i64* %7
%45 = add i64 %44, -1
store i64 %45, i64* %7
br label %28
46: ; preds = %41, %28
%47 = load i32, i32* %4
%48 = load i8*, i8** %8
%49 = load i32, i32* %6
%50 = call i32 @mpz_set_str(i32 %47, i8* %48, i32 %49)
store i32 %50, i32* %9
%51 = load i8*, i8** %8
%52 = call i32 @free(i8* %51)
%53 = load i32, i32* %9
ret i32 %53
}

LLVM IR (-O2):
@.str = [4 x i8] c" \09+\00"
define i32 @string2mpz(i32 %0, i8* %1, i32 %2) {
%4 = tail call i32 @strspn(i8* %1, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%5 = sext i32 %4 to i64
%6 = getelementptr inbounds i8, i8* %1, i64 %5
%7 = tail call i32 @strlen(i8* %6)
%8 = icmp eq i32 %7, 0
br i1 %8, label %9, label %11
9: ; preds = %3
%10 = tail call i32 @mpz_set_ui(i32 %0, i32 0)
br label %11
11: ; preds = %9, %3
%12 = tail call i8* @strdup(i8* %6)
%13 = tail call i32 @strlen(i8* %12)
%14 = add nsw i32 %13, -1
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds i8, i8* %12, i64 %15
%17 = load i8, i8* %16
%18 = icmp eq i8 %17, 10
br i1 %18, label %23, label %28
19: ; preds = %23
%20 = getelementptr inbounds i8, i8* %12, i64 %27
%21 = load i8, i8* %20
%22 = icmp eq i8 %21, 10
br i1 %22, label %23, label %28
23: ; preds = %11, %19
%24 = phi i8* [ %20, %19 ], [ %16, %11 ]
%25 = phi i64 [ %27, %19 ], [ %15, %11 ]
store i8 0, i8* %24
%26 = icmp eq i64 %25, 0
%27 = add i64 %25, -1
br i1 %26, label %28, label %19
28: ; preds = %19, %23, %11
%29 = tail call i32 @mpz_set_str(i32 %0, i8* %12, i32 %2)
%30 = tail call i32 @free(i8* %12)
ret i32 %29
}