#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 char wchar_t;

/* Variables and functions */
int /*<<< orphan*/ printf(char *, ...);
long long wcstoll(char *, char **, int);
int main(void) {
  wchar_t *wcs;
  wchar_t *stopwcs;
  long long val;
  wcs = L"1234567890123456789";
  printf("wcs = `%ls`\n", wcs);
  val = wcstoll(wcs, &stopwcs, 10);
  printf("wcstoll = %lld\n", val);
  printf("Stopped scan at `%ls`\n", stopwcs);
  if (val != 1234567890123456789LL) {
    printf("Wrong answer\n");
    return 1;
  }
  printf("OK\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rsi
lea    0xf0b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rdi
lea    -0x18(%rbp),%rsi
mov    $0xa,%edx
call   1040 <wcstoll@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rsi
lea    0xef0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%rsi
lea    0xeee(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movabs $0x112210f47de98115,%rax
10 22 11
cmp    %rax,-0x20(%rbp)
je     11b4 <main+0x94>
lea    0xee3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    11c9 <main+0xa9>
lea    0xed7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
lea    0xf16(%rip),%rdi
lea    0xebf(%rip),%rbx
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rsp,%rsi
mov    %rbx,%rdi
mov    $0xa,%edx
call   1050 <wcstoll@plt>
mov    %rax,%rbx
lea    0xef8(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    (%rsp),%rsi
lea    0xef3(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
movabs $0x112210f47de98115,%rax
10 22 11
xor    %ebp,%ebp
cmp    %rax,%rbx
setne  %bpl
lea    0xee9(%rip),%rax
lea    0xee5(%rip),%rdi
cmove  %rax,%rdi
call   1030 <puts@plt>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [20 x i32] [i32 49, i32 50, i32 51, i32 52, i32 53, i32 54, i32 55, i32 56, i32 57, i32 48, i32 49, i32 50, i32 51, i32 52, i32 53, i32 54, i32 55, i32 56, i32 57, i32 0]
@.str.1 = [13 x i8] c"wcs = `%ls`\0A\00"
@.str.2 = [16 x i8] c"wcstoll = %lld\0A\00"
@.str.3 = [23 x i8] c"Stopped scan at `%ls`\0A\00"
@.str.4 = [14 x i8] c"Wrong answer\0A\00"
@.str.5 = [4 x i8] c"OK\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i64
store i32 0, i32* %1
store i8* bitcast ([20 x i32]* @.str to i8*), i8** %2
%5 = load i8*, i8** %2
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i8* %5)
%7 = load i8*, i8** %2
%8 = call i64 @wcstoll(i8* %7, i8** %3, i32 10)
store i64 %8, i64* %4
%9 = load i64, i64* %4
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i64 %9)
%11 = load i8*, i8** %3
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0), i8* %11)
%13 = load i64, i64* %4
%14 = icmp ne i64 %13, 1234567890123456789
br i1 %14, label %15, label %17
15: ; preds = %0
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0))
store i32 1, i32* %1
br label %19
17: ; preds = %0
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0))
store i32 0, i32* %1
br label %19
19: ; preds = %17, %15
%20 = load i32, i32* %1
ret i32 %20
}

LLVM IR (-O2):
@.str = [20 x i32] [i32 49, i32 50, i32 51, i32 52, i32 53, i32 54, i32 55, i32 56, i32 57, i32 48, i32 49, i32 50, i32 51, i32 52, i32 53, i32 54, i32 55, i32 56, i32 57, i32 0]
@.str.1 = [13 x i8] c"wcs = `%ls`\0A\00"
@.str.2 = [16 x i8] c"wcstoll = %lld\0A\00"
@.str.3 = [23 x i8] c"Stopped scan at `%ls`\0A\00"
@str = [3 x i8] c"OK\00"
@str.6 = [13 x i8] c"Wrong answer\00"
define i32 @main() {
%1 = alloca i8*
%2 = bitcast i8** %1 to i8*
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i8* bitcast ([20 x i32]* @.str to i8*))
%4 = call i64 @wcstoll(i8* bitcast ([20 x i32]* @.str to i8*), i8** %1, i32 10)
%5 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i64 %4)
%6 = load i8*, i8** %1
%7 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0), i8* %6)
%8 = icmp eq i64 %4, 1234567890123456789
%9 = select i1 %8, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @str, i64 0, i64 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @str.6, i64 0, i64 0)
%10 = xor i1 %8, true
%11 = zext i1 %10 to i32
%12 = call i32 @puts(i8* dereferenceable(1) %9)
ret i32 %11
}