#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*/ fileno(int /*<<< orphan*/);
scalar_t__ isatty(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ stdout;
int main(void) {
  int i;
  if (isatty(fileno(stdout))) {
    for (i = 0; i < 5; i++) {
      printf("ABCDE\n");
    }
  } else {
    printf("-----header-----\n");
    for (i = 0; i < 5; i++) {
      printf("ABCDE\n");
    }
    printf("-----footer-----\n");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2e9a(%rip),%rax
mov    (%rax),%edi
call   1050 <fileno@plt>
mov    %eax,%edi
call   1030 <isatty@plt>
cmp    $0x0,%rax
je     118e <main+0x5e>
movl   $0x0,-0x8(%rbp)
cmpl   $0x5,-0x8(%rbp)
jge    1189 <main+0x59>
lea    0xe8a(%rip),%rdi
call   1040 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1165 <main+0x35>
jmp    11d1 <main+0xa1>
lea    0xe72(%rip),%rdi
call   1040 <printf@plt>
movl   $0x0,-0x8(%rbp)
cmpl   $0x5,-0x8(%rbp)
jge    11c5 <main+0x95>
lea    0xe4e(%rip),%rdi
call   1040 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    11a1 <main+0x71>
lea    0xe4d(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
mov    0x2ea5(%rip),%rax
mov    (%rax),%edi
call   1050 <fileno@plt>
mov    %eax,%edi
call   1040 <isatty@plt>
test   %rax,%rax
je     1157 <main+0x27>
lea    0xecd(%rip),%r14
jmp    1176 <main+0x46>
lea    0xea2(%rip),%rdi
call   1030 <puts@plt>
lea    0xeb8(%rip),%rdi
call   1030 <puts@plt>
lea    0xe9b(%rip),%r14
lea    0xea5(%rip),%rbx
mov    %rbx,%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
call   1030 <puts@plt>
mov    %r14,%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@stdout = global i32 0
@.str = [7 x i8] c"ABCDE\0A\00"
@.str.1 = [18 x i8] c"-----header-----\0A\00"
@.str.2 = [18 x i8] c"-----footer-----\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
store i32 0, i32* %1
%3 = load i32, i32* @stdout
%4 = call i32 @fileno(i32 %3)
%5 = call i64 @isatty(i32 %4)
%6 = icmp ne i64 %5, 0
br i1 %6, label %7, label %17
7: ; preds = %0
store i32 0, i32* %2
br label %8
8: ; preds = %13, %7
%9 = load i32, i32* %2
%10 = icmp slt i32 %9, 5
br i1 %10, label %11, label %16
11: ; preds = %8
%12 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
br label %13
13: ; preds = %11
%14 = load i32, i32* %2
%15 = add nsw i32 %14, 1
store i32 %15, i32* %2
br label %8
16: ; preds = %8
br label %29
17: ; preds = %0
%18 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %2
br label %19
19: ; preds = %24, %17
%20 = load i32, i32* %2
%21 = icmp slt i32 %20, 5
br i1 %21, label %22, label %27
22: ; preds = %19
%23 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
br label %24
24: ; preds = %22
%25 = load i32, i32* %2
%26 = add nsw i32 %25, 1
store i32 %26, i32* %2
br label %19
27: ; preds = %19
%28 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0))
br label %29
29: ; preds = %27, %16
ret i32 0
}

LLVM IR (-O2):
@stdout = global i32 0
@str = [17 x i8] c"-----header-----\00"
@str.3 = [17 x i8] c"-----footer-----\00"
@str.5 = [6 x i8] c"ABCDE\00"
define i32 @main() {
%1 = load i32, i32* @stdout
%2 = tail call i32 @fileno(i32 %1)
%3 = tail call i64 @isatty(i32 %2)
%4 = icmp eq i64 %3, 0
br i1 %4, label %5, label %8
5: ; preds = %0
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str, i64 0, i64 0))
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @str.5, i64 0, i64 0))
br label %8
8: ; preds = %0, %5
%9 = phi i8* [ getelementptr inbounds ([6 x i8], [6 x i8]* @str.5, i64 0, i64 0), %5 ], [ getelementptr inbounds ([6 x i8], [6 x i8]* @str.5, i64 0, i64 0), %0 ]
%10 = phi i8* [ getelementptr inbounds ([17 x i8], [17 x i8]* @str.3, i64 0, i64 0), %5 ], [ getelementptr inbounds ([6 x i8], [6 x i8]* @str.5, i64 0, i64 0), %0 ]
%11 = tail call i32 @puts(i8* dereferenceable(1) %9)
%12 = tail call i32 @puts(i8* dereferenceable(1) %9)
%13 = tail call i32 @puts(i8* dereferenceable(1) %9)
%14 = tail call i32 @puts(i8* dereferenceable(1) %9)
%15 = tail call i32 @puts(i8* dereferenceable(1) %10)
ret i32 0
}