#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*/ EXIT_FAILURE;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int sscanf(char *, char *, int *, ...);
int /*<<< orphan*/ stderr;
void function(char *buffer) {
  int a, b, c;
  if (sscanf(buffer, "%d %d %d", &a, &b, &c) != 3) {
    a = 1;
    if (sscanf(buffer, "%d %d", &b, &c) != 2) {
      b = 2;
      if (sscanf(buffer, "%d", &c) != 1) {
        fprintf(stderr, "Bad input: %s", buffer);
        exit(EXIT_FAILURE);
      }
    }
  }
}


x86 assembly (clang, -O0):
<function>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xeb9(%rip),%rsi
lea    -0xc(%rbp),%rdx
lea    -0x10(%rbp),%rcx
lea    -0x14(%rbp),%r8
mov    $0x0,%al
call   1040 <sscanf@plt>
cmp    $0x3,%eax
je     11e4 <function+0xb4>
movl   $0x1,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe8e(%rip),%rsi
lea    -0x10(%rbp),%rdx
lea    -0x14(%rbp),%rcx
mov    $0x0,%al
call   1040 <sscanf@plt>
cmp    $0x2,%eax
je     11df <function+0xaf>
movl   $0x2,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe67(%rip),%rsi
lea    -0x14(%rbp),%rdx
mov    $0x0,%al
call   1040 <sscanf@plt>
cmp    $0x1,%eax
je     11da <function+0xaa>
mov    0x2e26(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
lea    0xe42(%rip),%rsi
call   1030 <fprintf@plt>
mov    0x2e05(%rip),%rax
mov    (%rax),%edi
call   1050 <exit@plt>
jmp    11df <function+0xaf>
jmp    11e4 <function+0xb4>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<function>:
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rbx
lea    0xec1(%rip),%rsi
lea    0xc(%rsp),%rdx
lea    0x8(%rsp),%rcx
lea    0x4(%rsp),%r8
xor    %eax,%eax
call   1040 <sscanf@plt>
cmp    $0x3,%eax
je     11a5 <function+0x75>
movl   $0x1,0xc(%rsp)
lea    0xe9a(%rip),%rsi
lea    0x8(%rsp),%rdx
lea    0x4(%rsp),%rcx
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <sscanf@plt>
cmp    $0x2,%eax
je     11a5 <function+0x75>
movl   $0x2,0x8(%rsp)
lea    0xe75(%rip),%rsi
lea    0x4(%rsp),%rdx
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <sscanf@plt>
cmp    $0x1,%eax
jne    11ab <function+0x7b>
add    $0x10,%rsp
pop    %rbx
ret
mov    0x2e2e(%rip),%rax
mov    (%rax),%edi
lea    0xe4e(%rip),%rsi
mov    %rbx,%rdx
call   1030 <fprintf@plt>
mov    0x2e0e(%rip),%rax
mov    (%rax),%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@.str = [9 x i8] c"%d %d %d\00"
@.str.1 = [6 x i8] c"%d %d\00"
@.str.2 = [3 x i8] c"%d\00"
@stderr = global i32 0
@.str.3 = [14 x i8] c"Bad input: %s\00"
@EXIT_FAILURE = global i32 0
define void @function(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i8* %0, i8** %2
%6 = load i8*, i8** %2
%7 = call i32 (i8*, i8*, i32*, ...) @sscanf(i8* %6, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32* %3, i32* %4, i32* %5)
%8 = icmp ne i32 %7, 3
br i1 %8, label %9, label %25
9: ; preds = %1
store i32 1, i32* %3
%10 = load i8*, i8** %2
%11 = call i32 (i8*, i8*, i32*, ...) @sscanf(i8* %10, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32* %4, i32* %5)
%12 = icmp ne i32 %11, 2
br i1 %12, label %13, label %24
13: ; preds = %9
store i32 2, i32* %4
%14 = load i8*, i8** %2
%15 = call i32 (i8*, i8*, i32*, ...) @sscanf(i8* %14, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %5)
%16 = icmp ne i32 %15, 1
br i1 %16, label %17, label %23
17: ; preds = %13
%18 = load i32, i32* @stderr
%19 = load i8*, i8** %2
%20 = call i32 @fprintf(i32 %18, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i8* %19)
%21 = load i32, i32* @EXIT_FAILURE
%22 = call i32 @exit(i32 %21)
unreachable
23: ; preds = %13
br label %24
24: ; preds = %23, %9
br label %25
25: ; preds = %24, %1
ret void
}

LLVM IR (-O2):
@.str = [9 x i8] c"%d %d %d\00"
@.str.1 = [6 x i8] c"%d %d\00"
@.str.2 = [3 x i8] c"%d\00"
@stderr = global i32 0
@.str.3 = [14 x i8] c"Bad input: %s\00"
@EXIT_FAILURE = global i32 0
define void @function(i8* %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = bitcast i32* %2 to i8*
%6 = bitcast i32* %3 to i8*
%7 = bitcast i32* %4 to i8*
%8 = call i32 (i8*, i8*, i32*, ...) @sscanf(i8* %0, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32* %2, i32* %3, i32* %4)
%9 = icmp eq i32 %8, 3
br i1 %9, label %21, label %10
10: ; preds = %1
store i32 1, i32* %2
%11 = call i32 (i8*, i8*, i32*, ...) @sscanf(i8* %0, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32* %3, i32* %4)
%12 = icmp eq i32 %11, 2
br i1 %12, label %21, label %13
13: ; preds = %10
store i32 2, i32* %3
%14 = call i32 (i8*, i8*, i32*, ...) @sscanf(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %4)
%15 = icmp eq i32 %14, 1
br i1 %15, label %21, label %16
16: ; preds = %13
%17 = load i32, i32* @stderr
%18 = call i32 @fprintf(i32 %17, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i8* %0)
%19 = load i32, i32* @EXIT_FAILURE
%20 = call i32 @exit(i32 %19)
unreachable
21: ; preds = %10, %13, %1
ret void
}