#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 */
unsigned long strtoul(char const *, char **, int);
int get_percent_arg(const char *arg, unsigned long *value) {
  unsigned long t;
  char *suffix;
  t = strtoul(arg, &suffix, 10);
  if (*suffix == '%') {
    suffix++;
  }
  if (*suffix != 0 || t > 100) {
    return 1;
  }
  *value = t;
  return 0;
}


x86 assembly (clang, -O0):
<get_percent_arg>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x28(%rbp),%rsi
mov    $0xa,%edx
call   1030 <strtoul@plt>
mov    %rax,-0x20(%rbp)
mov    -0x28(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x25,%eax
jne    1152 <get_percent_arg+0x42>
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    116d <get_percent_arg+0x5d>
cmpq   $0x64,-0x20(%rbp)
jbe    1179 <get_percent_arg+0x69>
movl   $0x1,-0x4(%rbp)
jmp    118b <get_percent_arg+0x7b>
mov    -0x20(%rbp),%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_percent_arg>:
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%rbx
lea    0x8(%rsp),%rsi
mov    $0xa,%edx
call   1030 <strtoul@plt>
mov    0x8(%rsp),%rcx
mov    (%rcx),%dl
cmp    $0x25,%dl
jne    1136 <get_percent_arg+0x26>
mov    0x1(%rcx),%dl
mov    $0x1,%ecx
test   %dl,%dl
jne    114a <get_percent_arg+0x3a>
cmp    $0x64,%rax
ja     114a <get_percent_arg+0x3a>
mov    %rax,(%rbx)
xor    %ecx,%ecx
mov    %ecx,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define i32 @get_percent_arg(i8* %0, i64* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i64*
%6 = alloca i64
%7 = alloca i8*
store i8* %0, i8** %4
store i64* %1, i64** %5
%8 = load i8*, i8** %4
%9 = call i64 @strtoul(i8* %8, i8** %7, i32 10)
store i64 %9, i64* %6
%10 = load i8*, i8** %7
%11 = load i8, i8* %10
%12 = sext i8 %11 to i32
%13 = icmp eq i32 %12, 37
br i1 %13, label %14, label %17
14: ; preds = %2
%15 = load i8*, i8** %7
%16 = getelementptr inbounds i8, i8* %15, i32 1
store i8* %16, i8** %7
br label %17
17: ; preds = %14, %2
%18 = load i8*, i8** %7
%19 = load i8, i8* %18
%20 = sext i8 %19 to i32
%21 = icmp ne i32 %20, 0
br i1 %21, label %25, label %22
22: ; preds = %17
%23 = load i64, i64* %6
%24 = icmp ugt i64 %23, 100
br i1 %24, label %25, label %26
25: ; preds = %22, %17
store i32 1, i32* %3
br label %29
26: ; preds = %22
%27 = load i64, i64* %6
%28 = load i64*, i64** %5
store i64 %27, i64* %28
store i32 0, i32* %3
br label %29
29: ; preds = %26, %25
%30 = load i32, i32* %3
ret i32 %30
}

LLVM IR (-O2):
define i32 @get_percent_arg(i8* %0, i64* nocapture writeonly %1) {
%3 = alloca i8*
%4 = bitcast i8** %3 to i8*
%5 = call i64 @strtoul(i8* %0, i8** %3, i32 10)
%6 = load i8*, i8** %3
%7 = load i8, i8* %6
%8 = icmp eq i8 %7, 37
br i1 %8, label %9, label %12
9: ; preds = %2
%10 = getelementptr inbounds i8, i8* %6, i64 1
%11 = load i8, i8* %10
br label %12
12: ; preds = %9, %2
%13 = phi i8 [ %11, %9 ], [ %7, %2 ]
%14 = icmp ne i8 %13, 0
%15 = icmp ugt i64 %5, 100
%16 = select i1 %14, i1 true, i1 %15
br i1 %16, label %18, label %17
17: ; preds = %12
store i64 %5, i64* %1
br label %18
18: ; preds = %12, %17
%19 = phi i32 [ 0, %17 ], [ 1, %12 ]
ret i32 %19
}