int main(void) {
  const char *string = "1234567abc";
  unsigned long x;
  char *remainderPtr;
  x = strtoul(string, &remainderPtr, 0);
  printf("%s\"%s\"\n%s%lu\n%s\"%s\"\n%s%lu\n", "The original string is ",
         string, "The converted value is ", x,
         "The remainder of the original string is ", remainderPtr,
         "The converted value minus 567 is ", x - 567);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x20(%rbp),%rsi
xor    %edx,%edx
call   1040 <strtoul@plt>
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rdx
mov    -0x18(%rbp),%r8
mov    -0x20(%rbp),%r11
mov    -0x18(%rbp),%rax
sub    $0x237,%rax
lea    0xea1(%rip),%rdi
lea    0xeb5(%rip),%rsi
lea    0xec6(%rip),%rcx
lea    0xed7(%rip),%r9
lea    0xef9(%rip),%r10
mov    %r11,(%rsp)
mov    %r10,0x8(%rsp)
mov    %rax,0x10(%rsp)
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
lea    0xed5(%rip),%r14
mov    %rsp,%rsi
mov    %r14,%rdi
xor    %edx,%edx
call   1040 <strtoul@plt>
lea    -0x237(%rax),%rbx
sub    $0x8,%rsp
lea    0xf35(%rip),%r10
lea    0xeba(%rip),%rdi
lea    0xece(%rip),%rsi
lea    0xedf(%rip),%rcx
lea    0xef0(%rip),%r9
mov    %r14,%rdx
mov    %rax,%r8
xor    %eax,%eax
push   %rbx
push   %r10
push   0x18(%rsp)
call   1030 <printf@plt>
add    $0x20,%rsp
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [11 x i8] c"1234567abc\00"
@.str.1 = [27 x i8] c"%s\22%s\22\0A%s%lu\0A%s\22%s\22\0A%s%lu\0A\00"
@.str.2 = [24 x i8] c"The original string is \00"
@.str.3 = [24 x i8] c"The converted value is \00"
@.str.4 = [41 x i8] c"The remainder of the original string is \00"
@.str.5 = [34 x i8] c"The converted value minus 567 is \00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca i64
%4 = alloca i8*
store i32 0, i32* %1
store i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8** %2
%5 = load i8*, i8** %2
%6 = call i64 @strtoul(i8* %5, i8** %4, i32 0)
store i64 %6, i64* %3
%7 = load i8*, i8** %2
%8 = load i64, i64* %3
%9 = load i8*, i8** %4
%10 = load i64, i64* %3
%11 = sub i64 %10, 567
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0), i8* %7, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0), i64 %8, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.4, i64 0, i64 0), i8* %9, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.5, i64 0, i64 0), i64 %11)
ret i32 0
}

LLVM IR (-O2):
@.str = [11 x i8] c"1234567abc\00"
@.str.1 = [27 x i8] c"%s\22%s\22\0A%s%lu\0A%s\22%s\22\0A%s%lu\0A\00"
@.str.2 = [24 x i8] c"The original string is \00"
@.str.3 = [24 x i8] c"The converted value is \00"
@.str.4 = [41 x i8] c"The remainder of the original string is \00"
@.str.5 = [34 x i8] c"The converted value minus 567 is \00"
define i32 @main() {
%1 = alloca i8*
%2 = bitcast i8** %1 to i8*
%3 = call i64 @strtoul(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8** %1, i32 0)
%4 = load i8*, i8** %1
%5 = add i64 %3, -567
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0), i64 %3, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.4, i64 0, i64 0), i8* %4, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.5, i64 0, i64 0), i64 %5)
ret i32 0
}