#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 *, int, ...);
int /*<<< orphan*/ sscanf(char *, char *, int *, ...);
int main() {
  int v1, v2;
  char s[] = "12 15";
  sscanf(s, "%d %d", &v1, &v2);
  printf("%d + %d = %d\n", v1, v2, v1 + v2);
  int day, month, year;
  char monthname[20], s2[] = "10 January 2017", s3[] = " 10/01/2017 ";
  sscanf(s2, "%d %s %d", &day, monthname, &year);
  printf("Date: %d-%s-%d\n", day, monthname, year);
  sscanf(s3, "%d/%d/%d", &day, &month, &year);
  printf("%d.%d.%d\n", day, month, year);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xecb(%rip),%eax
mov    %eax,-0x12(%rbp)
mov    0xec5(%rip),%ax
mov    %ax,-0xe(%rbp)
lea    -0x12(%rbp),%rdi
lea    0xeb8(%rip),%rsi
lea    -0x8(%rbp),%rdx
lea    -0xc(%rbp),%rcx
mov    $0x0,%al
call   1040 <sscanf@plt>
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
mov    -0x8(%rbp),%ecx
add    -0xc(%rbp),%ecx
lea    0xe9c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0xee2(%rip),%rax
mov    %rax,-0x50(%rbp)
mov    0xedf(%rip),%rax
mov    %rax,-0x48(%rbp)
mov    0xe86(%rip),%rax
mov    %rax,-0x5d(%rbp)
mov    0xe84(%rip),%eax
mov    %eax,-0x55(%rbp)
mov    0xe7f(%rip),%al
mov    %al,-0x51(%rbp)
lea    -0x50(%rbp),%rdi
lea    -0x40(%rbp),%rcx
lea    0xe6e(%rip),%rsi
lea    -0x18(%rbp),%rdx
lea    -0x20(%rbp),%r8
mov    $0x0,%al
call   1040 <sscanf@plt>
mov    -0x18(%rbp),%esi
lea    -0x40(%rbp),%rdx
mov    -0x20(%rbp),%ecx
lea    0xe57(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x5d(%rbp),%rdi
lea    0xe55(%rip),%rsi
lea    -0x18(%rbp),%rdx
lea    -0x1c(%rbp),%rcx
lea    -0x20(%rbp),%r8
mov    $0x0,%al
call   1040 <sscanf@plt>
mov    -0x18(%rbp),%esi
mov    -0x1c(%rbp),%edx
mov    -0x20(%rbp),%ecx
lea    0xe3b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x60,%rsp
movw   $0x35,0x14(%rsp)
movl   $0x31203231,0x10(%rsp)
31
lea    0xec7(%rip),%rsi
lea    0x10(%rsp),%rdi
lea    0x1c(%rsp),%rdx
lea    0x18(%rsp),%rcx
xor    %eax,%eax
call   1040 <sscanf@plt>
mov    0x1c(%rsp),%esi
mov    0x18(%rsp),%edx
lea    (%rdx,%rsi,1),%ecx
lea    0xea5(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
movaps 0xeeb(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
movabs $0x20373130322f31,%rax
mov    %rax,0x25(%rsp)
movabs $0x322f31302f303120,%rax
31 2f 32
mov    %rax,0x20(%rsp)
lea    0xe88(%rip),%rsi
lea    0x30(%rsp),%rdi
lea    0x8(%rsp),%r14
lea    0x40(%rsp),%rbx
lea    0x4(%rsp),%r15
mov    %r14,%rdx
mov    %rbx,%rcx
mov    %r15,%r8
xor    %eax,%eax
call   1040 <sscanf@plt>
mov    0x8(%rsp),%esi
mov    0x4(%rsp),%ecx
lea    0xe5e(%rip),%rdi
mov    %rbx,%rdx
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xe5d(%rip),%rsi
lea    0x20(%rsp),%rdi
lea    0xc(%rsp),%rcx
mov    %r14,%rdx
mov    %r15,%r8
xor    %eax,%eax
call   1040 <sscanf@plt>
mov    0x8(%rsp),%esi
mov    0xc(%rsp),%edx
mov    0x4(%rsp),%ecx
lea    0xe3c(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x60,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@__const.main.s = [6 x i8] c"12 15\00"
@.str = [6 x i8] c"%d %d\00"
@.str.1 = [14 x i8] c"%d + %d = %d\0A\00"
@__const.main.s2 = [16 x i8] c"10 January 2017\00"
@__const.main.s3 = [13 x i8] c" 10/01/2017 \00"
@.str.2 = [9 x i8] c"%d %s %d\00"
@.str.3 = [16 x i8] c"Date: %d-%s-%d\0A\00"
@.str.4 = [9 x i8] c"%d/%d/%d\00"
@.str.5 = [10 x i8] c"%d.%d.%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca [6 x i8]
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca [20 x i8]
%9 = alloca [16 x i8]
%10 = alloca [13 x i8]
store i32 0, i32* %1
%11 = bitcast [6 x i8]* %4 to i8*
%12 = getelementptr inbounds [6 x i8], [6 x i8]* %4, i64 0, i64 0
%13 = call i32 (i8*, i8*, i32*, ...) @sscanf(i8* %12, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32* %2, i32* %3)
%14 = load i32, i32* %2
%15 = load i32, i32* %3
%16 = load i32, i32* %2
%17 = load i32, i32* %3
%18 = add nsw i32 %16, %17
%19 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i32 %14, i32 %15, i32 %18)
%20 = bitcast [16 x i8]* %9 to i8*
%21 = bitcast [13 x i8]* %10 to i8*
%22 = getelementptr inbounds [16 x i8], [16 x i8]* %9, i64 0, i64 0
%23 = getelementptr inbounds [20 x i8], [20 x i8]* %8, i64 0, i64 0
%24 = call i32 (i8*, i8*, i32*, ...) @sscanf(i8* %22, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i32* %5, i8* %23, i32* %7)
%25 = load i32, i32* %5
%26 = getelementptr inbounds [20 x i8], [20 x i8]* %8, i64 0, i64 0
%27 = load i32, i32* %7
%28 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i32 %25, i8* %26, i32 %27)
%29 = getelementptr inbounds [13 x i8], [13 x i8]* %10, i64 0, i64 0
%30 = call i32 (i8*, i8*, i32*, ...) @sscanf(i8* %29, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0), i32* %5, i32* %6, i32* %7)
%31 = load i32, i32* %5
%32 = load i32, i32* %6
%33 = load i32, i32* %7
%34 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0), i32 %31, i32 %32, i32 %33)
ret i32 0
}

LLVM IR (-O2):
@__const.main.s = [6 x i8] c"12 15\00"
@.str = [6 x i8] c"%d %d\00"
@.str.1 = [14 x i8] c"%d + %d = %d\0A\00"
@__const.main.s2 = [16 x i8] c"10 January 2017\00"
@__const.main.s3 = [13 x i8] c" 10/01/2017 \00"
@.str.2 = [9 x i8] c"%d %s %d\00"
@.str.3 = [16 x i8] c"Date: %d-%s-%d\0A\00"
@.str.4 = [9 x i8] c"%d/%d/%d\00"
@.str.5 = [10 x i8] c"%d.%d.%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [6 x i8]
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca [20 x i8]
%8 = alloca [16 x i8]
%9 = alloca [13 x i8]
%10 = bitcast i32* %1 to i8*
%11 = bitcast i32* %2 to i8*
%12 = getelementptr inbounds [6 x i8], [6 x i8]* %3, i64 0, i64 0
%13 = call i32 (i8*, i8*, i32*, ...) @sscanf(i8* %12, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32* %1, i32* %2)
%14 = load i32, i32* %1
%15 = load i32, i32* %2
%16 = add nsw i32 %15, %14
%17 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i32 %14, i32 %15, i32 %16)
%18 = bitcast i32* %4 to i8*
%19 = bitcast i32* %5 to i8*
%20 = bitcast i32* %6 to i8*
%21 = getelementptr inbounds [20 x i8], [20 x i8]* %7, i64 0, i64 0
%22 = getelementptr inbounds [16 x i8], [16 x i8]* %8, i64 0, i64 0
%23 = getelementptr inbounds [13 x i8], [13 x i8]* %9, i64 0, i64 0
%24 = call i32 (i8*, i8*, i32*, ...) @sscanf(i8* %22, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i32* %4, i8* %21, i32* %6)
%25 = load i32, i32* %4
%26 = load i32, i32* %6
%27 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i32 %25, i8* %21, i32 %26)
%28 = call i32 (i8*, i8*, i32*, ...) @sscanf(i8* %23, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0), i32* %4, i32* %5, i32* %6)
%29 = load i32, i32* %4
%30 = load i32, i32* %5
%31 = load i32, i32* %6
%32 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0), i32 %29, i32 %30, i32 %31)
ret i32 0
}