#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*/ printf(char *, char const *, unsigned long, char *, char *);
unsigned long strtoul(char const *, char **, int /*<<< orphan*/);
int main() {
  unsigned long int x = 0;
  char *p = NULL;
  const char *pList[] = {"   10M", "  10m",  "+20M",   "+ 30M",   "1G",
                         "12 M",   "  13 M", "w 10 M", " w 10 M", NULL};
  int i = 0;
  for (i = 0; pList[i] != NULL; i++) {
    x = strtoul(pList[i], &p, 0);
    printf("[%s] = [%lu], p = [%s], [%s]\n", pList[i], x, p,
           p == pList[i] ? "error" : "success");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movl   $0x0,-0x4(%rbp)
movq   $0x0,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
lea    -0x70(%rbp),%rdi
lea    0x2c73(%rip),%rsi
mov    $0x50,%edx
call   1040 <memcpy@plt>
movl   $0x0,-0x74(%rbp)
movl   $0x0,-0x74(%rbp)
movslq -0x74(%rbp),%rax
cmpq   $0x0,-0x70(%rbp,%rax,8)
je     11ea <main+0xba>
movslq -0x74(%rbp),%rax
mov    -0x70(%rbp,%rax,8),%rdi
lea    -0x18(%rbp),%rsi
xor    %edx,%edx
call   1050 <strtoul@plt>
mov    %rax,-0x10(%rbp)
movslq -0x74(%rbp),%rax
mov    -0x70(%rbp,%rax,8),%rsi
mov    -0x10(%rbp),%rdx
mov    -0x18(%rbp),%rcx
mov    -0x18(%rbp),%rdi
movslq -0x74(%rbp),%rax
mov    -0x70(%rbp,%rax,8),%r9
lea    0xe91(%rip),%r8
lea    0xe84(%rip),%rax
cmp    %r9,%rdi
cmove  %rax,%r8
lea    0xe58(%rip),%rdi
call   1030 <printf@plt>
mov    -0x74(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x74(%rbp)
jmp    1175 <main+0x45>
xor    %eax,%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
movq   $0x0,0x8(%rsp)
lea    0xec3(%rip),%r12
lea    0x8(%rsp),%r14
mov    %r12,%rdi
mov    %r14,%rsi
xor    %edx,%edx
call   1040 <strtoul@plt>
mov    0x8(%rsp),%rcx
cmp    %r12,%rcx
lea    0xeef(%rip),%r13
lea    0xeee(%rip),%rbx
mov    %rbx,%r8
cmove  %r13,%r8
lea    0xebc(%rip),%r15
mov    %r15,%rdi
mov    %r12,%rsi
mov    %rax,%rdx
call   1030 <printf@plt>
lea    0xe7f(%rip),%r12
mov    %r12,%rdi
mov    %r14,%rsi
xor    %edx,%edx
call   1040 <strtoul@plt>
mov    0x8(%rsp),%rcx
cmp    %r12,%rcx
mov    %rbx,%r8
cmove  %r13,%r8
mov    %r15,%rdi
mov    %r12,%rsi
mov    %rax,%rdx
call   1030 <printf@plt>
lea    0xe54(%rip),%r12
mov    %r12,%rdi
mov    %r14,%rsi
xor    %edx,%edx
call   1040 <strtoul@plt>
mov    0x8(%rsp),%rcx
cmp    %r12,%rcx
mov    %rbx,%r8
cmove  %r13,%r8
mov    %r15,%rdi
mov    %r12,%rsi
mov    %rax,%rdx
call   1030 <printf@plt>
lea    0xe28(%rip),%r12
mov    %r12,%rdi
mov    %r14,%rsi
xor    %edx,%edx
call   1040 <strtoul@plt>
mov    0x8(%rsp),%rcx
cmp    %r12,%rcx
mov    %rbx,%r8
cmove  %r13,%r8
mov    %r15,%rdi
mov    %r12,%rsi
mov    %rax,%rdx
call   1030 <printf@plt>
lea    0xdfd(%rip),%r12
mov    %r12,%rdi
mov    %r14,%rsi
xor    %edx,%edx
call   1040 <strtoul@plt>
mov    0x8(%rsp),%rcx
cmp    %r12,%rcx
mov    %rbx,%r8
cmove  %r13,%r8
mov    %r15,%rdi
mov    %r12,%rsi
mov    %rax,%rdx
call   1030 <printf@plt>
lea    0xdcf(%rip),%r12
mov    %r12,%rdi
mov    %r14,%rsi
xor    %edx,%edx
call   1040 <strtoul@plt>
mov    0x8(%rsp),%rcx
cmp    %r12,%rcx
mov    %rbx,%r8
cmove  %r13,%r8
mov    %r15,%rdi
mov    %r12,%rsi
mov    %rax,%rdx
call   1030 <printf@plt>
lea    0xda3(%rip),%r12
mov    %r12,%rdi
mov    %r14,%rsi
xor    %edx,%edx
call   1040 <strtoul@plt>
mov    0x8(%rsp),%rcx
cmp    %r12,%rcx
mov    %rbx,%r8
cmove  %r13,%r8
mov    %r15,%rdi
mov    %r12,%rsi
mov    %rax,%rdx
call   1030 <printf@plt>
lea    0xd7a(%rip),%r12
mov    %r12,%rdi
mov    %r14,%rsi
xor    %edx,%edx
call   1040 <strtoul@plt>
mov    0x8(%rsp),%rcx
cmp    %r12,%rcx
mov    %rbx,%r8
cmove  %r13,%r8
mov    %r15,%rdi
mov    %r12,%rsi
mov    %rax,%rdx
call   1030 <printf@plt>
lea    0xd48(%rip),%r12
mov    %r12,%rdi
mov    %r14,%rsi
xor    %edx,%edx
call   1040 <strtoul@plt>
mov    0x8(%rsp),%rcx
cmp    %r12,%rcx
cmove  %r13,%rbx
mov    %r15,%rdi
mov    %r12,%rsi
mov    %rax,%rdx
mov    %rbx,%r8
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [7 x i8] c" 10M\00"
@.str.1 = [6 x i8] c" 10m\00"
@.str.2 = [5 x i8] c"+20M\00"
@.str.3 = [6 x i8] c"+ 30M\00"
@.str.4 = [3 x i8] c"1G\00"
@.str.5 = [5 x i8] c"12 M\00"
@.str.6 = [7 x i8] c" 13 M\00"
@.str.7 = [7 x i8] c"w 10 M\00"
@.str.8 = [8 x i8] c" w 10 M\00"
@__const.main.pList = [10 x i8*] [i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i32 0, i32 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i32 0, i32 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i32 0, i32 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i32 0, i32 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.8, i32 0, i32 0), i8* null]
@.str.9 = [30 x i8] c"[%s] = [%lu], p = [%s], [%s]\0A\00"
@.str.10 = [6 x i8] c"error\00"
@.str.11 = [8 x i8] c"success\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i64
%3 = alloca i8*
%4 = alloca [10 x i8*]
%5 = alloca i32
store i32 0, i32* %1
store i64 0, i64* %2
store i8* null, i8** %3
%6 = bitcast [10 x i8*]* %4 to i8*
store i32 0, i32* %5
store i32 0, i32* %5
br label %7
7: ; preds = %34, %0
%8 = load i32, i32* %5
%9 = sext i32 %8 to i64
%10 = getelementptr inbounds [10 x i8*], [10 x i8*]* %4, i64 0, i64 %9
%11 = load i8*, i8** %10
%12 = icmp ne i8* %11, null
br i1 %12, label %13, label %37
13: ; preds = %7
%14 = load i32, i32* %5
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds [10 x i8*], [10 x i8*]* %4, i64 0, i64 %15
%17 = load i8*, i8** %16
%18 = call i64 @strtoul(i8* %17, i8** %3, i32 0)
store i64 %18, i64* %2
%19 = load i32, i32* %5
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds [10 x i8*], [10 x i8*]* %4, i64 0, i64 %20
%22 = load i8*, i8** %21
%23 = load i64, i64* %2
%24 = load i8*, i8** %3
%25 = load i8*, i8** %3
%26 = load i32, i32* %5
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds [10 x i8*], [10 x i8*]* %4, i64 0, i64 %27
%29 = load i8*, i8** %28
%30 = icmp eq i8* %25, %29
%31 = zext i1 %30 to i64
%32 = select i1 %30, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.10, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.11, i64 0, i64 0)
%33 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.9, i64 0, i64 0), i8* %22, i64 %23, i8* %24, i8* %32)
br label %34
34: ; preds = %13
%35 = load i32, i32* %5
%36 = add nsw i32 %35, 1
store i32 %36, i32* %5
br label %7
37: ; preds = %7
ret i32 0
}

LLVM IR (-O2):
@.str = [7 x i8] c" 10M\00"
@.str.1 = [6 x i8] c" 10m\00"
@.str.2 = [5 x i8] c"+20M\00"
@.str.3 = [6 x i8] c"+ 30M\00"
@.str.4 = [3 x i8] c"1G\00"
@.str.5 = [5 x i8] c"12 M\00"
@.str.6 = [7 x i8] c" 13 M\00"
@.str.7 = [7 x i8] c"w 10 M\00"
@.str.8 = [8 x i8] c" w 10 M\00"
@.str.9 = [30 x i8] c"[%s] = [%lu], p = [%s], [%s]\0A\00"
@.str.10 = [6 x i8] c"error\00"
@.str.11 = [8 x i8] c"success\00"
define i32 @main() {
%1 = alloca i8*
%2 = bitcast i8** %1 to i8*
store i8* null, i8** %1
%3 = call i64 @strtoul(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8** %1, i32 0)
%4 = load i8*, i8** %1
%5 = icmp eq i8* %4, getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0)
%6 = select i1 %5, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.10, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.11, i64 0, i64 0)
%7 = tail call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i64 %3, i8* %4, i8* %6)
%8 = call i64 @strtoul(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8** %1, i32 0)
%9 = load i8*, i8** %1
%10 = icmp eq i8* %9, getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0)
%11 = select i1 %10, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.10, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.11, i64 0, i64 0)
%12 = tail call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i64 %8, i8* %9, i8* %11)
%13 = call i64 @strtoul(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8** %1, i32 0)
%14 = load i8*, i8** %1
%15 = icmp eq i8* %14, getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0)
%16 = select i1 %15, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.10, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.11, i64 0, i64 0)
%17 = tail call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i64 %13, i8* %14, i8* %16)
%18 = call i64 @strtoul(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i8** %1, i32 0)
%19 = load i8*, i8** %1
%20 = icmp eq i8* %19, getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0)
%21 = select i1 %20, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.10, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.11, i64 0, i64 0)
%22 = tail call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i64 %18, i8* %19, i8* %21)
%23 = call i64 @strtoul(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8** %1, i32 0)
%24 = load i8*, i8** %1
%25 = icmp eq i8* %24, getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0)
%26 = select i1 %25, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.10, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.11, i64 0, i64 0)
%27 = tail call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i64 %23, i8* %24, i8* %26)
%28 = call i64 @strtoul(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), i8** %1, i32 0)
%29 = load i8*, i8** %1
%30 = icmp eq i8* %29, getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0)
%31 = select i1 %30, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.10, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.11, i64 0, i64 0)
%32 = tail call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), i64 %28, i8* %29, i8* %31)
%33 = call i64 @strtoul(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0), i8** %1, i32 0)
%34 = load i8*, i8** %1
%35 = icmp eq i8* %34, getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0)
%36 = select i1 %35, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.10, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.11, i64 0, i64 0)
%37 = tail call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0), i64 %33, i8* %34, i8* %36)
%38 = call i64 @strtoul(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0), i8** %1, i32 0)
%39 = load i8*, i8** %1
%40 = icmp eq i8* %39, getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0)
%41 = select i1 %40, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.10, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.11, i64 0, i64 0)
%42 = tail call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0), i64 %38, i8* %39, i8* %41)
%43 = call i64 @strtoul(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.8, i64 0, i64 0), i8** %1, i32 0)
%44 = load i8*, i8** %1
%45 = icmp eq i8* %44, getelementptr inbounds ([8 x i8], [8 x i8]* @.str.8, i64 0, i64 0)
%46 = select i1 %45, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.10, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.11, i64 0, i64 0)
%47 = tail call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.8, i64 0, i64 0), i64 %43, i8* %44, i8* %46)
ret i32 0
}