#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 int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ feof(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, int);
int /*<<< orphan*/ fscanf(int /*<<< orphan*/ *, char *, int *);
int main() {
  FILE *f1, *f2;
  f1 = fopen("input.txt", "r");
  f2 = fopen("output.txt", "w");
  int k, s = 0;
  while (1) {
    fscanf(f1, "%d", &k);
    if (!feof(f1))
      switch (k) {
      case 1:
        s += 50;
        break;
      case 2:
        s += 60;
        break;
      case 3:
        s += 100;
        break;
      case 4:
        s += 30;
        break;
      }
    else
      break;
  }
  fprintf(f2, "%d", s);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rdi
lea    0xebd(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x10(%rbp)
lea    0xeaf(%rip),%rdi
lea    0xeb3(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe9a(%rip),%rsi
lea    -0x1c(%rbp),%rdx
call   1030 <fscanf@plt>
mov    -0x10(%rbp),%rdi
call   1050 <feof@plt>
cmp    $0x0,%eax
jne    120b <main+0xcb>
mov    -0x1c(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x28(%rbp)
sub    $0x3,%eax
ja     1206 <main+0xc6>
mov    -0x28(%rbp),%rax
lea    0xe36(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x20(%rbp),%eax
add    $0x32,%eax
mov    %eax,-0x20(%rbp)
jmp    1206 <main+0xc6>
mov    -0x20(%rbp),%eax
add    $0x3c,%eax
mov    %eax,-0x20(%rbp)
jmp    1206 <main+0xc6>
mov    -0x20(%rbp),%eax
add    $0x64,%eax
mov    %eax,-0x20(%rbp)
jmp    1206 <main+0xc6>
mov    -0x20(%rbp),%eax
add    $0x1e,%eax
mov    %eax,-0x20(%rbp)
jmp    1210 <main+0xd0>
jmp    1215 <main+0xd5>
jmp    1184 <main+0x44>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%edx
lea    0xe06(%rip),%rsi
call   1040 <fprintf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xebe(%rip),%rdi
lea    0xec1(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,%rbx
lea    0xeb4(%rip),%rdi
lea    0xeb8(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,%r14
lea    0xeab(%rip),%rsi
lea    0x4(%rsp),%rdx
mov    %rbx,%rdi
call   1030 <fscanf@plt>
mov    %rbx,%rdi
call   1050 <feof@plt>
xor    %ebp,%ebp
test   %eax,%eax
je     11bb <main+0x7b>
lea    0xe89(%rip),%rsi
mov    %r14,%rdi
mov    %ebp,%edx
call   1040 <fprintf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
xor    %ebp,%ebp
lea    0xe65(%rip),%r15
lea    0x4(%rsp),%r12
lea    0xe30(%rip),%r13
jmp    120a <main+0xca>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
add    $0x1e,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %r12,%rdx
call   1030 <fscanf@plt>
mov    %rbx,%rdi
call   1050 <feof@plt>
test   %eax,%eax
jne    1199 <main+0x59>
mov    0x4(%rsp),%eax
add    $0xffffffff,%eax
cmp    $0x3,%eax
ja     11f0 <main+0xb0>
movslq 0x0(%r13,%rax,4),%rax
add    %r13,%rax
jmp    *%rax
add    $0x32,%ebp
jmp    11f0 <main+0xb0>
cs nopw 0x0(%rax,%rax,1)
nop
add    $0x3c,%ebp
jmp    11f0 <main+0xb0>
cs nopw 0x0(%rax,%rax,1)
nop
add    $0x64,%ebp
jmp    11f0 <main+0xb0>

LLVM IR (-O0):
@.str = [10 x i8] c"input.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [11 x i8] c"output.txt\00"
@.str.3 = [2 x i8] c"w\00"
@.str.4 = [3 x i8] c"%d\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
%6 = call i32* @fopen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %6, i32** %2
%7 = call i32* @fopen(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32* %7, i32** %3
store i32 0, i32* %5
br label %8
8: ; preds = %0, %30
%9 = load i32*, i32** %2
%10 = call i32 @fscanf(i32* %9, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %4)
%11 = load i32*, i32** %2
%12 = call i32 @feof(i32* %11)
%13 = icmp ne i32 %12, 0
br i1 %13, label %29, label %14
14: ; preds = %8
%15 = load i32, i32* %4
switch i32 %15, label %28 [
i32 1, label %16
i32 2, label %19
i32 3, label %22
i32 4, label %25
]
16: ; preds = %14
%17 = load i32, i32* %5
%18 = add nsw i32 %17, 50
store i32 %18, i32* %5
br label %28
19: ; preds = %14
%20 = load i32, i32* %5
%21 = add nsw i32 %20, 60
store i32 %21, i32* %5
br label %28
22: ; preds = %14
%23 = load i32, i32* %5
%24 = add nsw i32 %23, 100
store i32 %24, i32* %5
br label %28
25: ; preds = %14
%26 = load i32, i32* %5
%27 = add nsw i32 %26, 30
store i32 %27, i32* %5
br label %28
28: ; preds = %14, %25, %22, %19, %16
br label %30
29: ; preds = %8
br label %31
30: ; preds = %28
br label %8
31: ; preds = %29
%32 = load i32*, i32** %3
%33 = load i32, i32* %5
%34 = call i32 @fprintf(i32* %32, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32 %33)
ret i32 0
}

LLVM IR (-O2):
@.str = [10 x i8] c"input.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [11 x i8] c"output.txt\00"
@.str.3 = [2 x i8] c"w\00"
@.str.4 = [3 x i8] c"%d\00"
define i32 @main() {
%1 = alloca i32
%2 = tail call i32* @fopen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%3 = tail call i32* @fopen(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%4 = bitcast i32* %1 to i8*
%5 = call i32 @fscanf(i32* %2, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %1)
%6 = call i32 @feof(i32* %2)
%7 = icmp eq i32 %6, 0
br i1 %7, label %8, label %24
8: ; preds = %0, %19
%9 = phi i32 [ %20, %19 ], [ 0, %0 ]
%10 = load i32, i32* %1
switch i32 %10, label %19 [
i32 1, label %11
i32 2, label %13
i32 3, label %15
i32 4, label %17
]
11: ; preds = %8
%12 = add nsw i32 %9, 50
br label %19
13: ; preds = %8
%14 = add nsw i32 %9, 60
br label %19
15: ; preds = %8
%16 = add nsw i32 %9, 100
br label %19
17: ; preds = %8
%18 = add nsw i32 %9, 30
br label %19
19: ; preds = %11, %13, %15, %17, %8
%20 = phi i32 [ %9, %8 ], [ %18, %17 ], [ %16, %15 ], [ %14, %13 ], [ %12, %11 ]
%21 = call i32 @fscanf(i32* %2, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %1)
%22 = call i32 @feof(i32* %2)
%23 = icmp eq i32 %22, 0
br i1 %23, label %8, label %24
24: ; preds = %19, %0
%25 = phi i32 [ 0, %0 ], [ %20, %19 ]
%26 = call i32 @fprintf(i32* %3, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32 %25)
ret i32 0
}