#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 uint8_t;

/* Variables and functions */
int rand();
void new_fire(uint8_t field[][80], int height, int numcol) {
  int x;
  for (x = 0; x < 80; x++) {
    field[height - 1][x] = numcol * ((rand() % 10) > 3);
  }
}


x86 assembly (clang, -O0):
<new_fire>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x50,-0x14(%rbp)
jge    1187 <new_fire+0x77>
mov    -0x10(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    $0x0,%al
call   1030 <rand@plt>
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,%eax
mov    -0x18(%rbp),%edx
cmp    $0x3,%eax
setg   %al
and    $0x1,%al
movzbl %al,%eax
imul   %eax,%edx
mov    -0x8(%rbp),%rax
mov    -0xc(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
imul   $0x140,%rcx,%rcx
add    %rcx,%rax
movslq -0x14(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1129 <new_fire+0x19>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<new_fire>:
push   %rbp
push   %r14
push   %rbx
mov    %edx,%r14d
add    $0xffffffff,%esi
movslq %esi,%rax
lea    (%rax,%rax,4),%rbx
shl    $0x6,%rbx
add    %rdi,%rbx
xor    %ebp,%ebp
nopw   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1030 <rand@plt>
cltq
imul   $0x66666667,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x22,%rcx
add    %edx,%ecx
add    %ecx,%ecx
lea    (%rcx,%rcx,4),%ecx
sub    %ecx,%eax
cmp    $0x4,%eax
mov    $0x0,%eax
cmovge %r14d,%eax
mov    %eax,(%rbx,%rbp,4)
add    $0x1,%rbp
cmp    $0x50,%rbp
jne    1130 <new_fire+0x20>
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define void @new_fire([80 x i32]* %0, i32 %1, i32 %2) {
%4 = alloca [80 x i32]*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store [80 x i32]* %0, [80 x i32]** %4
store i32 %1, i32* %5
store i32 %2, i32* %6
store i32 0, i32* %7
br label %8
8: ; preds = %26, %3
%9 = load i32, i32* %7
%10 = icmp slt i32 %9, 80
br i1 %10, label %11, label %29
11: ; preds = %8
%12 = load i32, i32* %6
%13 = call i32 (...) @rand()
%14 = srem i32 %13, 10
%15 = icmp sgt i32 %14, 3
%16 = zext i1 %15 to i32
%17 = mul nsw i32 %12, %16
%18 = load [80 x i32]*, [80 x i32]** %4
%19 = load i32, i32* %5
%20 = sub nsw i32 %19, 1
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds [80 x i32], [80 x i32]* %18, i64 %21
%23 = load i32, i32* %7
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds [80 x i32], [80 x i32]* %22, i64 0, i64 %24
store i32 %17, i32* %25
br label %26
26: ; preds = %11
%27 = load i32, i32* %7
%28 = add nsw i32 %27, 1
store i32 %28, i32* %7
br label %8
29: ; preds = %8
ret void
}

LLVM IR (-O2):
define void @new_fire([80 x i32]* nocapture writeonly %0, i32 %1, i32 %2) {
%4 = add nsw i32 %1, -1
%5 = sext i32 %4 to i64
br label %6
6: ; preds = %3, %6
%7 = phi i64 [ 0, %3 ], [ %13, %6 ]
%8 = tail call i32 (...) @rand()
%9 = srem i32 %8, 10
%10 = icmp sgt i32 %9, 3
%11 = select i1 %10, i32 %2, i32 0
%12 = getelementptr inbounds [80 x i32], [80 x i32]* %0, i64 %5, i64 %7
store i32 %11, i32* %12
%13 = add nuw nsw i64 %7, 1
%14 = icmp eq i64 %13, 80
br i1 %14, label %15, label %6
15: ; preds = %6
ret void
}