#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 scanf(char *, int *);
int stk_init(int *stk) {
  int retval = 0;
  int i;
  for (i = 15; i >= 0; i--)
    if (scanf("%d", &stk[i]) != 1) {
      stk[i] = i;
      retval = 1;
    }
  return retval;
}


x86 assembly (clang, -O0):
<stk_init>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0xf,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
jl     1180 <stk_init+0x70>
mov    -0x8(%rbp),%rsi
movslq -0x10(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rsi
lea    0xeb6(%rip),%rdi
call   1030 <scanf@plt>
cmp    $0x1,%eax
je     116d <stk_init+0x5d>
mov    -0x10(%rbp),%edx
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
movl   $0x1,-0xc(%rbp)
jmp    1172 <stk_init+0x62>
mov    -0x10(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x10(%rbp)
jmp    112a <stk_init+0x1a>
mov    -0xc(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<stk_init>:
push   %rbp
push   %r14
push   %rbx
mov    %rdi,%rbx
lea    0x3c(%rdi),%rbp
lea    0xede(%rip),%rdi
mov    %rbp,%rsi
call   1030 <scanf@plt>
xor    %r14d,%r14d
cmp    $0x1,%eax
je     113f <stk_init+0x2f>
movl   $0xf,0x0(%rbp)
mov    $0x1,%r14d
lea    0x38(%rbx),%rbp
lea    0xeb6(%rip),%rdi
mov    %rbp,%rsi
call   1030 <scanf@plt>
cmp    $0x1,%eax
je     1164 <stk_init+0x54>
movl   $0xe,0x0(%rbp)
mov    $0x1,%r14d
lea    0x34(%rbx),%rbp
lea    0xe91(%rip),%rdi
mov    %rbp,%rsi
call   1030 <scanf@plt>
cmp    $0x1,%eax
je     1189 <stk_init+0x79>
movl   $0xd,0x0(%rbp)
mov    $0x1,%r14d
lea    0x30(%rbx),%rbp
lea    0xe6c(%rip),%rdi
mov    %rbp,%rsi
call   1030 <scanf@plt>
cmp    $0x1,%eax
je     11ae <stk_init+0x9e>
movl   $0xc,0x0(%rbp)
mov    $0x1,%r14d
lea    0x2c(%rbx),%rbp
lea    0xe47(%rip),%rdi
mov    %rbp,%rsi
call   1030 <scanf@plt>
cmp    $0x1,%eax
je     11d3 <stk_init+0xc3>
movl   $0xb,0x0(%rbp)
mov    $0x1,%r14d
lea    0x28(%rbx),%rbp
lea    0xe22(%rip),%rdi
mov    %rbp,%rsi
call   1030 <scanf@plt>
cmp    $0x1,%eax
je     11f8 <stk_init+0xe8>
movl   $0xa,0x0(%rbp)
mov    $0x1,%r14d
lea    0x24(%rbx),%rbp
lea    0xdfd(%rip),%rdi
mov    %rbp,%rsi
call   1030 <scanf@plt>
cmp    $0x1,%eax
je     121d <stk_init+0x10d>
movl   $0x9,0x0(%rbp)
mov    $0x1,%r14d
lea    0x20(%rbx),%rbp
lea    0xdd8(%rip),%rdi
mov    %rbp,%rsi
call   1030 <scanf@plt>
cmp    $0x1,%eax
je     1242 <stk_init+0x132>
movl   $0x8,0x0(%rbp)
mov    $0x1,%r14d
lea    0x1c(%rbx),%rbp
lea    0xdb3(%rip),%rdi
mov    %rbp,%rsi
call   1030 <scanf@plt>
cmp    $0x1,%eax
je     1267 <stk_init+0x157>
movl   $0x7,0x0(%rbp)
mov    $0x1,%r14d
lea    0x18(%rbx),%rbp
lea    0xd8e(%rip),%rdi
mov    %rbp,%rsi
call   1030 <scanf@plt>
cmp    $0x1,%eax
je     128c <stk_init+0x17c>
movl   $0x6,0x0(%rbp)
mov    $0x1,%r14d
lea    0x14(%rbx),%rbp
lea    0xd69(%rip),%rdi
mov    %rbp,%rsi
call   1030 <scanf@plt>
cmp    $0x1,%eax
je     12b1 <stk_init+0x1a1>
movl   $0x5,0x0(%rbp)
mov    $0x1,%r14d
lea    0x10(%rbx),%rbp
lea    0xd44(%rip),%rdi
mov    %rbp,%rsi
call   1030 <scanf@plt>
cmp    $0x1,%eax
je     12d6 <stk_init+0x1c6>
movl   $0x4,0x0(%rbp)
mov    $0x1,%r14d
lea    0xc(%rbx),%rbp
lea    0xd1f(%rip),%rdi
mov    %rbp,%rsi
call   1030 <scanf@plt>
cmp    $0x1,%eax
je     12fb <stk_init+0x1eb>
movl   $0x3,0x0(%rbp)
mov    $0x1,%r14d
lea    0x8(%rbx),%rbp
lea    0xcfa(%rip),%rdi
mov    %rbp,%rsi
call   1030 <scanf@plt>
cmp    $0x1,%eax
je     1320 <stk_init+0x210>
movl   $0x2,0x0(%rbp)
mov    $0x1,%r14d
lea    0x4(%rbx),%rbp
lea    0xcd5(%rip),%rdi
mov    %rbp,%rsi
call   1030 <scanf@plt>
cmp    $0x1,%eax
je     1345 <stk_init+0x235>
movl   $0x1,0x0(%rbp)
mov    $0x1,%r14d
lea    0xcb4(%rip),%rdi
mov    %rbx,%rsi
call   1030 <scanf@plt>
cmp    $0x1,%eax
je     1365 <stk_init+0x255>
movl   $0x0,(%rbx)
mov    $0x1,%r14d
mov    %r14d,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
define i32 @stk_init(i32* %0) {
%2 = alloca i32*
%3 = alloca i32
%4 = alloca i32
store i32* %0, i32** %2
store i32 0, i32* %3
store i32 15, i32* %4
br label %5
5: ; preds = %22, %1
%6 = load i32, i32* %4
%7 = icmp sge i32 %6, 0
br i1 %7, label %8, label %25
8: ; preds = %5
%9 = load i32*, i32** %2
%10 = load i32, i32* %4
%11 = sext i32 %10 to i64
%12 = getelementptr inbounds i32, i32* %9, i64 %11
%13 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %12)
%14 = icmp ne i32 %13, 1
br i1 %14, label %15, label %21
15: ; preds = %8
%16 = load i32, i32* %4
%17 = load i32*, i32** %2
%18 = load i32, i32* %4
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds i32, i32* %17, i64 %19
store i32 %16, i32* %20
store i32 1, i32* %3
br label %21
21: ; preds = %15, %8
br label %22
22: ; preds = %21
%23 = load i32, i32* %4
%24 = add nsw i32 %23, -1
store i32 %24, i32* %4
br label %5
25: ; preds = %5
%26 = load i32, i32* %3
ret i32 %26
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
define i32 @stk_init(i32* %0) {
%2 = getelementptr inbounds i32, i32* %0, i64 15
%3 = tail call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
%4 = icmp eq i32 %3, 1
br i1 %4, label %6, label %5
5: ; preds = %1
store i32 15, i32* %2
br label %6
6: ; preds = %1, %5
%7 = phi i32 [ 1, %5 ], [ 0, %1 ]
%8 = getelementptr inbounds i32, i32* %0, i64 14
%9 = tail call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %8)
%10 = icmp eq i32 %9, 1
br i1 %10, label %12, label %11
11: ; preds = %6
store i32 14, i32* %8
br label %12
12: ; preds = %11, %6
%13 = phi i32 [ 1, %11 ], [ %7, %6 ]
%14 = getelementptr inbounds i32, i32* %0, i64 13
%15 = tail call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %14)
%16 = icmp eq i32 %15, 1
br i1 %16, label %18, label %17
17: ; preds = %12
store i32 13, i32* %14
br label %18
18: ; preds = %17, %12
%19 = phi i32 [ 1, %17 ], [ %13, %12 ]
%20 = getelementptr inbounds i32, i32* %0, i64 12
%21 = tail call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %20)
%22 = icmp eq i32 %21, 1
br i1 %22, label %24, label %23
23: ; preds = %18
store i32 12, i32* %20
br label %24
24: ; preds = %23, %18
%25 = phi i32 [ 1, %23 ], [ %19, %18 ]
%26 = getelementptr inbounds i32, i32* %0, i64 11
%27 = tail call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %26)
%28 = icmp eq i32 %27, 1
br i1 %28, label %30, label %29
29: ; preds = %24
store i32 11, i32* %26
br label %30
30: ; preds = %29, %24
%31 = phi i32 [ 1, %29 ], [ %25, %24 ]
%32 = getelementptr inbounds i32, i32* %0, i64 10
%33 = tail call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %32)
%34 = icmp eq i32 %33, 1
br i1 %34, label %36, label %35
35: ; preds = %30
store i32 10, i32* %32
br label %36
36: ; preds = %35, %30
%37 = phi i32 [ 1, %35 ], [ %31, %30 ]
%38 = getelementptr inbounds i32, i32* %0, i64 9
%39 = tail call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %38)
%40 = icmp eq i32 %39, 1
br i1 %40, label %42, label %41
41: ; preds = %36
store i32 9, i32* %38
br label %42
42: ; preds = %41, %36
%43 = phi i32 [ 1, %41 ], [ %37, %36 ]
%44 = getelementptr inbounds i32, i32* %0, i64 8
%45 = tail call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %44)
%46 = icmp eq i32 %45, 1
br i1 %46, label %48, label %47
47: ; preds = %42
store i32 8, i32* %44
br label %48
48: ; preds = %47, %42
%49 = phi i32 [ 1, %47 ], [ %43, %42 ]
%50 = getelementptr inbounds i32, i32* %0, i64 7
%51 = tail call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %50)
%52 = icmp eq i32 %51, 1
br i1 %52, label %54, label %53
53: ; preds = %48
store i32 7, i32* %50
br label %54
54: ; preds = %53, %48
%55 = phi i32 [ 1, %53 ], [ %49, %48 ]
%56 = getelementptr inbounds i32, i32* %0, i64 6
%57 = tail call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %56)
%58 = icmp eq i32 %57, 1
br i1 %58, label %60, label %59
59: ; preds = %54
store i32 6, i32* %56
br label %60
60: ; preds = %59, %54
%61 = phi i32 [ 1, %59 ], [ %55, %54 ]
%62 = getelementptr inbounds i32, i32* %0, i64 5
%63 = tail call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %62)
%64 = icmp eq i32 %63, 1
br i1 %64, label %66, label %65
65: ; preds = %60
store i32 5, i32* %62
br label %66
66: ; preds = %65, %60
%67 = phi i32 [ 1, %65 ], [ %61, %60 ]
%68 = getelementptr inbounds i32, i32* %0, i64 4
%69 = tail call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %68)
%70 = icmp eq i32 %69, 1
br i1 %70, label %72, label %71
71: ; preds = %66
store i32 4, i32* %68
br label %72
72: ; preds = %71, %66
%73 = phi i32 [ 1, %71 ], [ %67, %66 ]
%74 = getelementptr inbounds i32, i32* %0, i64 3
%75 = tail call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %74)
%76 = icmp eq i32 %75, 1
br i1 %76, label %78, label %77
77: ; preds = %72
store i32 3, i32* %74
br label %78
78: ; preds = %77, %72
%79 = phi i32 [ 1, %77 ], [ %73, %72 ]
%80 = getelementptr inbounds i32, i32* %0, i64 2
%81 = tail call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %80)
%82 = icmp eq i32 %81, 1
br i1 %82, label %84, label %83
83: ; preds = %78
store i32 2, i32* %80
br label %84
84: ; preds = %83, %78
%85 = phi i32 [ 1, %83 ], [ %79, %78 ]
%86 = getelementptr inbounds i32, i32* %0, i64 1
%87 = tail call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %86)
%88 = icmp eq i32 %87, 1
br i1 %88, label %90, label %89
89: ; preds = %84
store i32 1, i32* %86
br label %90
90: ; preds = %89, %84
%91 = phi i32 [ 1, %89 ], [ %85, %84 ]
%92 = tail call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %0)
%93 = icmp eq i32 %92, 1
br i1 %93, label %95, label %94
94: ; preds = %90
store i32 0, i32* %0
br label %95
95: ; preds = %94, %90
%96 = phi i32 [ 1, %94 ], [ %91, %90 ]
ret i32 %96
}