#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 */
struct game_state {
  int dummy;
};
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ draw_row(struct game_state const *, int /*<<< orphan*/ *,
                            int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *);
void state_draw(const struct game_state *state, FILE *fp) {
  int row, col;
  for (row = (6) - 1; row >= 0; --row) {
    for (col = 0; col < (7); ++col) {
      fprintf(fp, "+-");
    }
    fprintf(fp, "+\n");
    draw_row(state, fp, row);
  }
  for (col = 0; col < (7); ++col) {
    fprintf(fp, "+-");
  }
  fprintf(fp, "+\n");
}


x86 assembly (clang, -O0):
<state_draw>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x5,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jl     119e <state_draw+0x7e>
movl   $0x0,-0x18(%rbp)
cmpl   $0x7,-0x18(%rbp)
jge    1170 <state_draw+0x50>
mov    -0x10(%rbp),%rdi
lea    0xea3(%rip),%rsi
call   1040 <fprintf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1148 <state_draw+0x28>
mov    -0x10(%rbp),%rdi
lea    0xe88(%rip),%rsi
call   1040 <fprintf@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
call   1030 <draw_row@plt>
mov    -0x14(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x14(%rbp)
jmp    1137 <state_draw+0x17>
movl   $0x0,-0x18(%rbp)
cmpl   $0x7,-0x18(%rbp)
jge    11cd <state_draw+0xad>
mov    -0x10(%rbp),%rdi
lea    0xe46(%rip),%rsi
call   1040 <fprintf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    11a5 <state_draw+0x85>
mov    -0x10(%rbp),%rdi
lea    0xe2b(%rip),%rsi
call   1040 <fprintf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<state_draw>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rsi,%rbx
mov    %rdi,%r14
mov    $0x5,%ebp
lea    0xec6(%rip),%r15
lea    0xec2(%rip),%r12
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    $0x2,%esi
mov    $0x1,%edx
mov    %r15,%rdi
mov    %rbx,%rcx
call   1040 <fwrite@plt>
mov    $0x2,%esi
mov    $0x1,%edx
mov    %r15,%rdi
mov    %rbx,%rcx
call   1040 <fwrite@plt>
mov    $0x2,%esi
mov    $0x1,%edx
mov    %r15,%rdi
mov    %rbx,%rcx
call   1040 <fwrite@plt>
mov    $0x2,%esi
mov    $0x1,%edx
mov    %r15,%rdi
mov    %rbx,%rcx
call   1040 <fwrite@plt>
mov    $0x2,%esi
mov    $0x1,%edx
mov    %r15,%rdi
mov    %rbx,%rcx
call   1040 <fwrite@plt>
mov    $0x2,%esi
mov    $0x1,%edx
mov    %r15,%rdi
mov    %rbx,%rcx
call   1040 <fwrite@plt>
mov    $0x2,%esi
mov    $0x1,%edx
mov    %r15,%rdi
mov    %rbx,%rcx
call   1040 <fwrite@plt>
mov    $0x2,%esi
mov    $0x1,%edx
mov    %r12,%rdi
mov    %rbx,%rcx
call   1040 <fwrite@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %ebp,%edx
call   1030 <draw_row@plt>
add    $0xffffffff,%ebp
jb     1150 <state_draw+0x30>
lea    0xdeb(%rip),%rbp
mov    $0x2,%esi
mov    $0x1,%edx
mov    %rbp,%rdi
mov    %rbx,%rcx
call   1040 <fwrite@plt>
mov    $0x2,%esi
mov    $0x1,%edx
mov    %rbp,%rdi
mov    %rbx,%rcx
call   1040 <fwrite@plt>
mov    $0x2,%esi
mov    $0x1,%edx
mov    %rbp,%rdi
mov    %rbx,%rcx
call   1040 <fwrite@plt>
mov    $0x2,%esi
mov    $0x1,%edx
mov    %rbp,%rdi
mov    %rbx,%rcx
call   1040 <fwrite@plt>
mov    $0x2,%esi
mov    $0x1,%edx
mov    %rbp,%rdi
mov    %rbx,%rcx
call   1040 <fwrite@plt>
mov    $0x2,%esi
mov    $0x1,%edx
mov    %rbp,%rdi
mov    %rbx,%rcx
call   1040 <fwrite@plt>
mov    $0x2,%esi
mov    $0x1,%edx
mov    %rbp,%rdi
mov    %rbx,%rcx
call   1040 <fwrite@plt>
lea    0xd54(%rip),%rdi
mov    $0x2,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <fwrite@plt>

LLVM IR (-O0):
%struct.game_state = type { i32 }
@.str = [3 x i8] c"+-\00"
@.str.1 = [3 x i8] c"+\0A\00"
define void @state_draw(%struct.game_state* %0, i32* %1) {
%3 = alloca %struct.game_state*
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i32
store %struct.game_state* %0, %struct.game_state** %3
store i32* %1, i32** %4
store i32 5, i32* %5
br label %7
7: ; preds = %27, %2
%8 = load i32, i32* %5
%9 = icmp sge i32 %8, 0
br i1 %9, label %10, label %30
10: ; preds = %7
store i32 0, i32* %6
br label %11
11: ; preds = %17, %10
%12 = load i32, i32* %6
%13 = icmp slt i32 %12, 7
br i1 %13, label %14, label %20
14: ; preds = %11
%15 = load i32*, i32** %4
%16 = call i32 @fprintf(i32* %15, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
br label %17
17: ; preds = %14
%18 = load i32, i32* %6
%19 = add nsw i32 %18, 1
store i32 %19, i32* %6
br label %11
20: ; preds = %11
%21 = load i32*, i32** %4
%22 = call i32 @fprintf(i32* %21, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%23 = load %struct.game_state*, %struct.game_state** %3
%24 = load i32*, i32** %4
%25 = load i32, i32* %5
%26 = call i32 @draw_row(%struct.game_state* %23, i32* %24, i32 %25)
br label %27
27: ; preds = %20
%28 = load i32, i32* %5
%29 = add nsw i32 %28, -1
store i32 %29, i32* %5
br label %7
30: ; preds = %7
store i32 0, i32* %6
br label %31
31: ; preds = %37, %30
%32 = load i32, i32* %6
%33 = icmp slt i32 %32, 7
br i1 %33, label %34, label %40
34: ; preds = %31
%35 = load i32*, i32** %4
%36 = call i32 @fprintf(i32* %35, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
br label %37
37: ; preds = %34
%38 = load i32, i32* %6
%39 = add nsw i32 %38, 1
store i32 %39, i32* %6
br label %31
40: ; preds = %31
%41 = load i32*, i32** %4
%42 = call i32 @fprintf(i32* %41, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
%struct.game_state = type { i32 }
@.str = [3 x i8] c"+-\00"
@.str.1 = [3 x i8] c"+\0A\00"
define void @state_draw(%struct.game_state* %0, i32* %1) {
br label %3
3: ; preds = %2, %3
%4 = phi i32 [ 5, %2 ], [ %14, %3 ]
%5 = tail call i64 @fwrite(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i64 2, i64 1, i32* %1)
%6 = tail call i64 @fwrite(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i64 2, i64 1, i32* %1)
%7 = tail call i64 @fwrite(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i64 2, i64 1, i32* %1)
%8 = tail call i64 @fwrite(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i64 2, i64 1, i32* %1)
%9 = tail call i64 @fwrite(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i64 2, i64 1, i32* %1)
%10 = tail call i64 @fwrite(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i64 2, i64 1, i32* %1)
%11 = tail call i64 @fwrite(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i64 2, i64 1, i32* %1)
%12 = tail call i64 @fwrite(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i64 2, i64 1, i32* %1)
%13 = tail call i32 @draw_row(%struct.game_state* %0, i32* %1, i32 %4)
%14 = add nsw i32 %4, -1
%15 = icmp eq i32 %4, 0
br i1 %15, label %16, label %3
16: ; preds = %3
%17 = tail call i64 @fwrite(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i64 2, i64 1, i32* %1)
%18 = tail call i64 @fwrite(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i64 2, i64 1, i32* %1)
%19 = tail call i64 @fwrite(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i64 2, i64 1, i32* %1)
%20 = tail call i64 @fwrite(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i64 2, i64 1, i32* %1)
%21 = tail call i64 @fwrite(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i64 2, i64 1, i32* %1)
%22 = tail call i64 @fwrite(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i64 2, i64 1, i32* %1)
%23 = tail call i64 @fwrite(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i64 2, i64 1, i32* %1)
%24 = tail call i64 @fwrite(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i64 2, i64 1, i32* %1)
ret void
}