#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 sscanf(char *, char *, int *, int *, int *, int *);
int main(int argc, char *argv[]) {
  int nf;
  int n;
  int month, day, year;
  static char date[] = "   12/  2 / 2008 ";
  printf("Extracting from '%s'\n", date);
  nf = sscanf(date, "%d /%d /%d%n", &month, &day, &year, &n);
  printf("%02d/%02d/%04d nf = %d, n = %d\n", month, day, year, nf, n);
  if (nf >= 3) {
    printf("Remainder = '%s'\n", &date[n]);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xec3(%rip),%rdi
lea    0x2efc(%rip),%rsi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0x2eee(%rip),%rdi
lea    0xebd(%rip),%rsi
lea    -0x1c(%rbp),%rdx
lea    -0x20(%rbp),%rcx
lea    -0x24(%rbp),%r8
lea    -0x18(%rbp),%r9
call   1040 <sscanf@plt>
mov    %eax,-0x14(%rbp)
mov    -0x1c(%rbp),%esi
mov    -0x20(%rbp),%edx
mov    -0x24(%rbp),%ecx
mov    -0x14(%rbp),%r8d
mov    -0x18(%rbp),%r9d
lea    0xe9a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x3,-0x14(%rbp)
jl     11b6 <main+0x96>
movslq -0x18(%rbp),%rax
lea    0x2e9b(%rip),%rsi
add    %rax,%rsi
lea    0xe94(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
sub    $0x18,%rsp
lea    0xed3(%rip),%rdi
lea    0x2f0c(%rip),%rbx
mov    %rbx,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xed1(%rip),%rsi
lea    0x14(%rsp),%rdx
lea    0x10(%rsp),%rcx
lea    0xc(%rsp),%r8
lea    0x8(%rsp),%r9
mov    %rbx,%rdi
call   1040 <sscanf@plt>
mov    %eax,%ebp
mov    0x14(%rsp),%esi
mov    0x10(%rsp),%edx
mov    0xc(%rsp),%ecx
mov    0x8(%rsp),%r9d
lea    0xea8(%rip),%rdi
mov    %eax,%r8d
xor    %eax,%eax
call   1030 <printf@plt>
cmp    $0x3,%ebp
jl     11a3 <main+0x83>
movslq 0x8(%rsp),%rax
add    %rax,%rbx
lea    0xeaa(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@main.date = internal global [18 x i8] c" 12/ 2 / 2008 \00"
@.str = [22 x i8] c"Extracting from '%s'\0A\00"
@.str.1 = [13 x i8] c"%d /%d /%d%n\00"
@.str.2 = [32 x i8] c"%02d/%02d/%04d nf = %d, n = %d\0A\00"
@.str.3 = [18 x i8] c"Remainder = '%s'\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([18 x i8], [18 x i8]* @main.date, i64 0, i64 0))
%12 = call i32 @sscanf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @main.date, i64 0, i64 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i32* %8, i32* %9, i32* %10, i32* %7)
store i32 %12, i32* %6
%13 = load i32, i32* %8
%14 = load i32, i32* %9
%15 = load i32, i32* %10
%16 = load i32, i32* %6
%17 = load i32, i32* %7
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0), i32 %13, i32 %14, i32 %15, i32 %16, i32 %17)
%19 = load i32, i32* %6
%20 = icmp sge i32 %19, 3
br i1 %20, label %21, label %26
21: ; preds = %2
%22 = load i32, i32* %7
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds [18 x i8], [18 x i8]* @main.date, i64 0, i64 %23
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0), i8* %24)
br label %26
26: ; preds = %21, %2
ret i32 0
}

LLVM IR (-O2):
@main.date = internal global [18 x i8] c" 12/ 2 / 2008 \00"
@.str = [22 x i8] c"Extracting from '%s'\0A\00"
@.str.1 = [13 x i8] c"%d /%d /%d%n\00"
@.str.2 = [32 x i8] c"%02d/%02d/%04d nf = %d, n = %d\0A\00"
@.str.3 = [18 x i8] c"Remainder = '%s'\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = bitcast i32* %3 to i8*
%8 = bitcast i32* %4 to i8*
%9 = bitcast i32* %5 to i8*
%10 = bitcast i32* %6 to i8*
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([18 x i8], [18 x i8]* @main.date, i64 0, i64 0))
%12 = call i32 @sscanf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @main.date, i64 0, i64 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i32* %4, i32* %5, i32* %6, i32* %3)
%13 = load i32, i32* %4
%14 = load i32, i32* %5
%15 = load i32, i32* %6
%16 = load i32, i32* %3
%17 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0), i32 %13, i32 %14, i32 %15, i32 %12, i32 %16)
%18 = icmp sgt i32 %12, 2
br i1 %18, label %19, label %24
19: ; preds = %2
%20 = load i32, i32* %3
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds [18 x i8], [18 x i8]* @main.date, i64 0, i64 %21
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0), i8* %22)
br label %24
24: ; preds = %19, %2
ret i32 0
}