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

/* Variables and functions */
int /*<<< orphan*/ _memset(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ _strstrip_nl(char *);
int atoi(char *);
int /*<<< orphan*/ atol(char *);
int /*<<< orphan*/ errx(int /*<<< orphan*/, char *);
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ printf(char *, char *, char *);
int /*<<< orphan*/ putc(char, int /*<<< orphan*/);
int /*<<< orphan*/ *stdin;
int /*<<< orphan*/ stdout;
int /*<<< orphan*/ strcasecmp(char *, char *);
char *strtok(char *, char *);
int main(int argc, char *argv[]) {
  FILE *fp = stdin;
  char buf[10024];
  int i;
  time_t t;
  int nest;
  int type;
  char *fn, *tok;
  if (argc > 1) {
    fp = fopen(argv[1], "r");
    if (!fp)
      errx(0, "main: fopen ");
  }
  while (1) {
    _memset(buf, 0, sizeof(buf));
    if (fgets(buf, sizeof(buf) - 1, fp) == NULL)
      break;
    _strstrip_nl(buf);
    tok = strtok(buf, ":");
    if (!tok)
      continue;
    nest = atoi(tok);
    tok = strtok(NULL, ":");
    if (!tok)
      continue;
    t = atol(tok);
    tok = strtok(NULL, ":");
    if (!tok)
      continue;
    if (!strcasecmp(tok, "enter"))
      type = 1;
    else
      type = 0;
    tok = strtok(NULL, "");
    if (!tok)
      continue;
    for (i = 0; i < nest; i++) {
      putc(' ', stdout);
    }
    printf("%s:%s\n", tok, type == 1 ? "entered" : "returned");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x2760,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2e18(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x18(%rbp)
cmpl   $0x1,-0x8(%rbp)
jle    1217 <main+0x67>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe23(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1212 <main+0x62>
xor    %edi,%edi
lea    0xdf3(%rip),%rsi
call   1040 <errx@plt>
jmp    1217 <main+0x67>
jmp    121c <main+0x6c>
lea    -0x2740(%rbp),%rdi
xor    %esi,%esi
mov    $0x2728,%edx
call   10d0 <_memset@plt>
lea    -0x2740(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    $0x2727,%esi
call   1060 <fgets@plt>
cmp    $0x0,%rax
jne    1253 <main+0xa3>
jmp    13d9 <main+0x229>
lea    -0x2740(%rbp),%rdi
call   1080 <_strstrip_nl@plt>
lea    -0x2740(%rbp),%rdi
lea    0xda0(%rip),%rsi
call   10b0 <strtok@plt>
mov    %rax,-0x2760(%rbp)
cmpq   $0x0,-0x2760(%rbp)
jne    128c <main+0xdc>
jmp    121c <main+0x6c>
mov    -0x2760(%rbp),%rdi
call   10c0 <atoi@plt>
mov    %eax,-0x274c(%rbp)
xor    %eax,%eax
mov    %eax,%edi
lea    0xd64(%rip),%rsi
call   10b0 <strtok@plt>
mov    %rax,-0x2760(%rbp)
cmpq   $0x0,-0x2760(%rbp)
jne    12c8 <main+0x118>
jmp    121c <main+0x6c>
mov    -0x2760(%rbp),%rdi
call   1090 <atol@plt>
mov    %eax,-0x2748(%rbp)
xor    %eax,%eax
mov    %eax,%edi
lea    0xd28(%rip),%rsi
call   10b0 <strtok@plt>
mov    %rax,-0x2760(%rbp)
cmpq   $0x0,-0x2760(%rbp)
jne    1304 <main+0x154>
jmp    121c <main+0x6c>
mov    -0x2760(%rbp),%rdi
lea    0xcfd(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%eax
jne    132f <main+0x17f>
movl   $0x1,-0x2750(%rbp)
jmp    1339 <main+0x189>
movl   $0x0,-0x2750(%rbp)
xor    %eax,%eax
mov    %eax,%edi
lea    0xcd7(%rip),%rsi
call   10b0 <strtok@plt>
mov    %rax,-0x2760(%rbp)
cmpq   $0x0,-0x2760(%rbp)
jne    1363 <main+0x1b3>
jmp    121c <main+0x6c>
movl   $0x0,-0x2744(%rbp)
mov    -0x2744(%rbp),%eax
cmp    -0x274c(%rbp),%eax
jge    13a6 <main+0x1f6>
mov    0x2c52(%rip),%rax
mov    (%rax),%esi
mov    $0x20,%edi
call   1070 <putc@plt>
mov    -0x2744(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2744(%rbp)
jmp    136d <main+0x1bd>
mov    -0x2760(%rbp),%rsi
mov    -0x2750(%rbp),%ecx
lea    0xc6a(%rip),%rdx
lea    0xc5b(%rip),%rax
cmp    $0x1,%ecx
cmove  %rax,%rdx
lea    0xc46(%rip),%rdi
call   1050 <printf@plt>
jmp    121c <main+0x6c>
xor    %eax,%eax
add    $0x2760,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x2738,%rsp
cmp    $0x2,%edi
jl     11e1 <main+0x41>
mov    0x8(%rsi),%rdi
lea    0xe52(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,%r12
test   %rax,%rax
jne    11eb <main+0x4b>
lea    0xe2b(%rip),%rsi
xor    %r12d,%r12d
xor    %edi,%edi
call   1040 <errx@plt>
jmp    11eb <main+0x4b>
mov    0x2e00(%rip),%rax
mov    (%rax),%r12
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x2728,%edx
call   10c0 <_memset@plt>
mov    %rbx,%rdi
mov    $0x2727,%esi
mov    %r12,%rdx
call   1060 <fgets@plt>
test   %rax,%rax
je     1317 <main+0x177>
lea    0x10(%rsp),%rbx
lea    0xde9(%rip),%r15
mov    0x2dad(%rip),%r14
jmp    1288 <main+0xe8>
cmpl   $0x0,0xc(%rsp)
lea    0xdeb(%rip),%rdx
lea    0xddc(%rip),%rax
cmove  %rax,%rdx
lea    0xdca(%rip),%rdi
mov    %r13,%rsi
call   1050 <printf@plt>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x2728,%edx
call   10c0 <_memset@plt>
mov    %rbx,%rdi
mov    $0x2727,%esi
mov    %r12,%rdx
call   1060 <fgets@plt>
test   %rax,%rax
je     1317 <main+0x177>
mov    %rbx,%rdi
call   1080 <_strstrip_nl@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   10a0 <strtok@plt>
test   %rax,%rax
je     1260 <main+0xc0>
mov    %rax,%rdi
call   10b0 <atoi@plt>
mov    %eax,%ebp
xor    %edi,%edi
mov    %r15,%rsi
call   10a0 <strtok@plt>
test   %rax,%rax
je     1260 <main+0xc0>
xor    %edi,%edi
mov    %r15,%rsi
call   10a0 <strtok@plt>
test   %rax,%rax
je     1260 <main+0xc0>
mov    %rax,%rdi
lea    0xd3d(%rip),%rsi
call   1030 <strcasecmp@plt>
mov    %eax,0xc(%rsp)
xor    %edi,%edi
lea    0xd37(%rip),%rsi
call   10a0 <strtok@plt>
test   %rax,%rax
je     1260 <main+0xc0>
mov    %rax,%r13
test   %ebp,%ebp
jle    122d <main+0x8d>
nopl   (%rax)
mov    (%r14),%esi
mov    $0x20,%edi
call   1070 <putc@plt>
add    $0xffffffff,%ebp
jne    1300 <main+0x160>
jmp    122d <main+0x8d>
xor    %eax,%eax
add    $0x2738,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stdin = global i32* null
@.str = [2 x i8] c"r\00"
@.str.1 = [13 x i8] c"main: fopen \00"
@.str.2 = [2 x i8] c":\00"
@.str.3 = [6 x i8] c"enter\00"
@.str.4 = [1 x i8] zeroinitializer
@stdout = global i32 0
@.str.5 = [7 x i8] c"%s:%s\0A\00"
@.str.6 = [8 x i8] c"entered\00"
@.str.7 = [9 x i8] c"returned\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca [10024 x i8]
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i8*
%13 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%14 = load i32*, i32** @stdin
store i32* %14, i32** %6
%15 = load i32, i32* %4
%16 = icmp sgt i32 %15, 1
br i1 %16, label %17, label %27
17: ; preds = %2
%18 = load i8**, i8*** %5
%19 = getelementptr inbounds i8*, i8** %18, i64 1
%20 = load i8*, i8** %19
%21 = call i32* @fopen(i8* %20, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %21, i32** %6
%22 = load i32*, i32** %6
%23 = icmp ne i32* %22, null
br i1 %23, label %26, label %24
24: ; preds = %17
%25 = call i32 @errx(i32 0, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0))
br label %26
26: ; preds = %24, %17
br label %27
27: ; preds = %26, %2
br label %28
28: ; preds = %27, %43, %50, %57, %68, %80
%29 = getelementptr inbounds [10024 x i8], [10024 x i8]* %7, i64 0, i64 0
%30 = call i32 @_memset(i8* %29, i32 0, i32 10024)
%31 = getelementptr inbounds [10024 x i8], [10024 x i8]* %7, i64 0, i64 0
%32 = load i32*, i32** %6
%33 = call i32* @fgets(i8* %31, i32 10023, i32* %32)
%34 = icmp eq i32* %33, null
br i1 %34, label %35, label %36
35: ; preds = %28
br label %87
36: ; preds = %28
%37 = getelementptr inbounds [10024 x i8], [10024 x i8]* %7, i64 0, i64 0
%38 = call i32 @_strstrip_nl(i8* %37)
%39 = getelementptr inbounds [10024 x i8], [10024 x i8]* %7, i64 0, i64 0
%40 = call i8* @strtok(i8* %39, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i8* %40, i8** %13
%41 = load i8*, i8** %13
%42 = icmp ne i8* %41, null
br i1 %42, label %44, label %43
43: ; preds = %36
br label %28
44: ; preds = %36
%45 = load i8*, i8** %13
%46 = call i32 @atoi(i8* %45)
store i32 %46, i32* %10
%47 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i8* %47, i8** %13
%48 = load i8*, i8** %13
%49 = icmp ne i8* %48, null
br i1 %49, label %51, label %50
50: ; preds = %44
br label %28
51: ; preds = %44
%52 = load i8*, i8** %13
%53 = call i32 @atol(i8* %52)
store i32 %53, i32* %9
%54 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i8* %54, i8** %13
%55 = load i8*, i8** %13
%56 = icmp ne i8* %55, null
br i1 %56, label %58, label %57
57: ; preds = %51
br label %28
58: ; preds = %51
%59 = load i8*, i8** %13
%60 = call i32 @strcasecmp(i8* %59, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
%61 = icmp ne i32 %60, 0
br i1 %61, label %63, label %62
62: ; preds = %58
store i32 1, i32* %11
br label %64
63: ; preds = %58
store i32 0, i32* %11
br label %64
64: ; preds = %63, %62
%65 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.4, i64 0, i64 0))
store i8* %65, i8** %13
%66 = load i8*, i8** %13
%67 = icmp ne i8* %66, null
br i1 %67, label %69, label %68
68: ; preds = %64
br label %28
69: ; preds = %64
store i32 0, i32* %8
br label %70
70: ; preds = %77, %69
%71 = load i32, i32* %8
%72 = load i32, i32* %10
%73 = icmp slt i32 %71, %72
br i1 %73, label %74, label %80
74: ; preds = %70
%75 = load i32, i32* @stdout
%76 = call i32 @putc(i8 signext 32, i32 %75)
br label %77
77: ; preds = %74
%78 = load i32, i32* %8
%79 = add nsw i32 %78, 1
store i32 %79, i32* %8
br label %70
80: ; preds = %70
%81 = load i8*, i8** %13
%82 = load i32, i32* %11
%83 = icmp eq i32 %82, 1
%84 = zext i1 %83 to i64
%85 = select i1 %83, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.7, i64 0, i64 0)
%86 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0), i8* %81, i8* %85)
br label %28
87: ; preds = %35
ret i32 0
}

LLVM IR (-O2):
@stdin = global i32* null
@.str = [2 x i8] c"r\00"
@.str.1 = [13 x i8] c"main: fopen \00"
@.str.2 = [2 x i8] c":\00"
@.str.3 = [6 x i8] c"enter\00"
@.str.4 = [1 x i8] zeroinitializer
@stdout = global i32 0
@.str.5 = [7 x i8] c"%s:%s\0A\00"
@.str.6 = [8 x i8] c"entered\00"
@.str.7 = [9 x i8] c"returned\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [10024 x i8]
%4 = load i32*, i32** @stdin
%5 = getelementptr inbounds [10024 x i8], [10024 x i8]* %3, i64 0, i64 0
%6 = icmp sgt i32 %0, 1
br i1 %6, label %7, label %14
7: ; preds = %2
%8 = getelementptr inbounds i8*, i8** %1, i64 1
%9 = load i8*, i8** %8
%10 = tail call i32* @fopen(i8* %9, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%11 = icmp eq i32* %10, null
br i1 %11, label %12, label %14
12: ; preds = %7
%13 = tail call i32 @errx(i32 0, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0))
br label %14
14: ; preds = %7, %12, %2
%15 = phi i32* [ %10, %7 ], [ null, %12 ], [ %4, %2 ]
%16 = call i32 @_memset(i8* %5, i32 0, i32 10024)
%17 = call i32* @fgets(i8* %5, i32 10023, i32* %15)
%18 = icmp eq i32* %17, null
br i1 %18, label %50, label %19
19: ; preds = %14, %46
%20 = call i32 @_strstrip_nl(i8* %5)
%21 = call i8* @strtok(i8* %5, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%22 = icmp eq i8* %21, null
br i1 %22, label %46, label %23
23: ; preds = %19
%24 = call i32 @atoi(i8* %21)
%25 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%26 = icmp eq i8* %25, null
br i1 %26, label %46, label %27
27: ; preds = %23
%28 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%29 = icmp eq i8* %28, null
br i1 %29, label %46, label %30
30: ; preds = %27
%31 = call i32 @strcasecmp(i8* %28, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
%32 = icmp eq i32 %31, 0
%33 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.4, i64 0, i64 0))
%34 = icmp eq i8* %33, null
br i1 %34, label %46, label %35
35: ; preds = %30
%36 = icmp sgt i32 %24, 0
br i1 %36, label %37, label %43
37: ; preds = %35, %37
%38 = phi i32 [ %41, %37 ], [ 0, %35 ]
%39 = load i32, i32* @stdout
%40 = call i32 @putc(i8 signext 32, i32 %39)
%41 = add nuw nsw i32 %38, 1
%42 = icmp eq i32 %41, %24
br i1 %42, label %43, label %37
43: ; preds = %37, %35
%44 = select i1 %32, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.7, i64 0, i64 0)
%45 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0), i8* %33, i8* %44)
br label %46
46: ; preds = %43, %19, %23, %27, %30
%47 = call i32 @_memset(i8* %5, i32 0, i32 10024)
%48 = call i32* @fgets(i8* %5, i32 10023, i32* %15)
%49 = icmp eq i32* %48, null
br i1 %49, label %50, label %19
50: ; preds = %46, %14
ret i32 0
}