#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*/ uint8_t;
typedef int /*<<< orphan*/ uint32_t;
typedef int /*<<< orphan*/ field;

/* Variables and functions */
int create_palette(int /*<<< orphan*/ *);
int /*<<< orphan*/ memset(int /*<<< orphan*/ **, int /*<<< orphan*/, int);
int /*<<< orphan*/ move_fire(int /*<<< orphan*/ **, int);
int /*<<< orphan*/ new_fire(int /*<<< orphan*/ **, int, int);
int /*<<< orphan*/ save_image(int, int /*<<< orphan*/ **, int /*<<< orphan*/ *);
int main(int argc, char *argv[]) {
  int i;
  uint8_t field[(8 + 2)][80];
  uint32_t palet[256];
  (void)argc;
  (void)argv;
  int numcol = create_palette(palet);
  memset(field, 0, sizeof(field));
  for (i = 0; i < 200; i++) {
    new_fire(field, (8 + 2), (i < 190) ? numcol : 0);
    move_fire(field, (8 + 2));
    save_image(i, field, palet);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10c0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x10a0(%rbp),%rdi
call   1060 <create_palette@plt>
mov    %eax,-0x10a4(%rbp)
lea    -0xca0(%rbp),%rdi
xor    %esi,%esi
mov    $0xc80,%edx
call   1040 <memset@plt>
movl   $0x0,-0x14(%rbp)
cmpl   $0xc8,-0x14(%rbp)
jge    1227 <main+0xd7>
lea    -0xca0(%rbp),%rax
mov    %rax,-0x10b0(%rbp)
cmpl   $0xbe,-0x14(%rbp)
jge    11ce <main+0x7e>
mov    -0x10a4(%rbp),%eax
mov    %eax,-0x10b4(%rbp)
jmp    11db <main+0x8b>
xor    %eax,%eax
mov    %eax,-0x10b4(%rbp)
jmp    11db <main+0x8b>
mov    -0x10b0(%rbp),%rdi
mov    -0x10b4(%rbp),%edx
mov    $0xa,%esi
call   1030 <new_fire@plt>
lea    -0xca0(%rbp),%rdi
mov    $0xa,%esi
call   1070 <move_fire@plt>
mov    -0x14(%rbp),%edi
lea    -0xca0(%rbp),%rsi
lea    -0x10a0(%rbp),%rdx
call   1050 <save_image@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1195 <main+0x45>
xor    %eax,%eax
add    $0x10c0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x1088,%rsp
mov    %rsp,%r14
mov    %r14,%rdi
call   1060 <create_palette@plt>
mov    %eax,%r15d
lea    0x400(%rsp),%rbx
xor    %ebp,%ebp
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0xc80,%edx
call   1040 <memset@plt>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
cmp    $0xbe,%ebp
mov    $0x0,%edx
cmovb  %r15d,%edx
mov    %rbx,%rdi
mov    $0xa,%esi
call   1030 <new_fire@plt>
mov    %rbx,%rdi
mov    $0xa,%esi
call   1070 <move_fire@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r14,%rdx
call   1050 <save_image@plt>
add    $0x1,%ebp
cmp    $0xc8,%ebp
jne    1190 <main+0x40>
xor    %eax,%eax
add    $0x1088,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca [10 x [80 x i32]]
%8 = alloca [256 x i32]
%9 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = load i32, i32* %4
%11 = load i8**, i8*** %5
%12 = getelementptr inbounds [256 x i32], [256 x i32]* %8, i64 0, i64 0
%13 = call i32 @create_palette(i32* %12)
store i32 %13, i32* %9
%14 = getelementptr inbounds [10 x [80 x i32]], [10 x [80 x i32]]* %7, i64 0, i64 0
%15 = bitcast [80 x i32]* %14 to i32**
%16 = call i32 @memset(i32** %15, i32 0, i32 3200)
store i32 0, i32* %6
br label %17
17: ; preds = %39, %2
%18 = load i32, i32* %6
%19 = icmp slt i32 %18, 200
br i1 %19, label %20, label %42
20: ; preds = %17
%21 = getelementptr inbounds [10 x [80 x i32]], [10 x [80 x i32]]* %7, i64 0, i64 0
%22 = bitcast [80 x i32]* %21 to i32**
%23 = load i32, i32* %6
%24 = icmp slt i32 %23, 190
br i1 %24, label %25, label %27
25: ; preds = %20
%26 = load i32, i32* %9
br label %28
27: ; preds = %20
br label %28
28: ; preds = %27, %25
%29 = phi i32 [ %26, %25 ], [ 0, %27 ]
%30 = call i32 @new_fire(i32** %22, i32 10, i32 %29)
%31 = getelementptr inbounds [10 x [80 x i32]], [10 x [80 x i32]]* %7, i64 0, i64 0
%32 = bitcast [80 x i32]* %31 to i32**
%33 = call i32 @move_fire(i32** %32, i32 10)
%34 = load i32, i32* %6
%35 = getelementptr inbounds [10 x [80 x i32]], [10 x [80 x i32]]* %7, i64 0, i64 0
%36 = bitcast [80 x i32]* %35 to i32**
%37 = getelementptr inbounds [256 x i32], [256 x i32]* %8, i64 0, i64 0
%38 = call i32 @save_image(i32 %34, i32** %36, i32* %37)
br label %39
39: ; preds = %28
%40 = load i32, i32* %6
%41 = add nsw i32 %40, 1
store i32 %41, i32* %6
br label %17
42: ; preds = %17
ret i32 0
}

LLVM IR (-O2):
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [10 x [80 x i32]]
%4 = alloca [256 x i32]
%5 = bitcast [10 x [80 x i32]]* %3 to i8*
%6 = bitcast [256 x i32]* %4 to i8*
%7 = getelementptr inbounds [256 x i32], [256 x i32]* %4, i64 0, i64 0
%8 = call i32 @create_palette(i32* %7)
%9 = bitcast [10 x [80 x i32]]* %3 to i32**
%10 = call i32 @memset(i32** %9, i32 0, i32 3200)
br label %11
11: ; preds = %2, %11
%12 = phi i32 [ 0, %2 ], [ %18, %11 ]
%13 = icmp ult i32 %12, 190
%14 = select i1 %13, i32 %8, i32 0
%15 = call i32 @new_fire(i32** %9, i32 10, i32 %14)
%16 = call i32 @move_fire(i32** %9, i32 10)
%17 = call i32 @save_image(i32 %12, i32** %9, i32* %7)
%18 = add nuw nsw i32 %12, 1
%19 = icmp eq i32 %18, 200
br i1 %19, label %20, label %11
20: ; preds = %11
ret i32 0
}