#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 wbuf {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ wbuf_write(struct wbuf *, float const *, int);
void write_fill(struct wbuf *buf, unsigned indices[3], float (*vertices)[2]) {
  static float const q[3][3] = {
      {0.f, 0.f, 1.f}, {0.f, 1.f, 1.f}, {1.f, 1.f, 1.f}};
  float(*p)[2];
  size_t i;
  for (i = 0; i < 3; i++) {
    p = vertices + indices[i];
    (void)wbuf_write(buf, *p, sizeof *p);
    (void)wbuf_write(buf, q[1], sizeof q[1]);
  }
}


x86 assembly (clang, -O0):
<write_fill>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movq   $0x0,-0x28(%rbp)
cmpq   $0x3,-0x28(%rbp)
jae    118d <write_fill+0x7d>
mov    -0x18(%rbp),%rax
mov    -0x10(%rbp),%rcx
mov    -0x28(%rbp),%rdx
mov    (%rcx,%rdx,4),%ecx
shl    $0x3,%rcx
add    %rcx,%rax
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    $0x8,%edx
call   1030 <wbuf_write@plt>
mov    -0x8(%rbp),%rdi
lea    0xe92(%rip),%rsi
add    $0xc,%rsi
mov    $0xc,%edx
call   1030 <wbuf_write@plt>
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
jmp    112c <write_fill+0x1c>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<write_fill>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%rbx
mov    (%rsi),%eax
lea    (%rdx,%rax,8),%rsi
mov    $0x8,%edx
call   1030 <wbuf_write@plt>
lea    0xed4(%rip),%r12
mov    %rbx,%rdi
mov    %r12,%rsi
mov    $0xc,%edx
call   1030 <wbuf_write@plt>
mov    0x4(%r15),%eax
lea    (%r14,%rax,8),%rsi
mov    %rbx,%rdi
mov    $0x8,%edx
call   1030 <wbuf_write@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
mov    $0xc,%edx
call   1030 <wbuf_write@plt>
mov    0x8(%r15),%eax
lea    (%r14,%rax,8),%rsi
mov    %rbx,%rdi
mov    $0x8,%edx
call   1030 <wbuf_write@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
mov    $0xc,%edx
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1030 <wbuf_write@plt>

LLVM IR (-O0):
%struct.wbuf = type { i32 }
@write_fill.q = internal constant [3 x [3 x float]] [[3 x float] [float 0.000000e+00, float 0.000000e+00, float 1.000000e+00], [3 x float] [float 0.000000e+00, float 1.000000e+00, float 1.000000e+00], [3 x float] [float 1.000000e+00, float 1.000000e+00, float 1.000000e+00]]
define void @write_fill(%struct.wbuf* %0, i32* %1, [2 x float]* %2) {
%4 = alloca %struct.wbuf*
%5 = alloca i32*
%6 = alloca [2 x float]*
%7 = alloca [2 x float]*
%8 = alloca i64
store %struct.wbuf* %0, %struct.wbuf** %4
store i32* %1, i32** %5
store [2 x float]* %2, [2 x float]** %6
store i64 0, i64* %8
br label %9
9: ; preds = %26, %3
%10 = load i64, i64* %8
%11 = icmp ult i64 %10, 3
br i1 %11, label %12, label %29
12: ; preds = %9
%13 = load [2 x float]*, [2 x float]** %6
%14 = load i32*, i32** %5
%15 = load i64, i64* %8
%16 = getelementptr inbounds i32, i32* %14, i64 %15
%17 = load i32, i32* %16
%18 = zext i32 %17 to i64
%19 = getelementptr inbounds [2 x float], [2 x float]* %13, i64 %18
store [2 x float]* %19, [2 x float]** %7
%20 = load %struct.wbuf*, %struct.wbuf** %4
%21 = load [2 x float]*, [2 x float]** %7
%22 = getelementptr inbounds [2 x float], [2 x float]* %21, i64 0, i64 0
%23 = call i32 @wbuf_write(%struct.wbuf* %20, float* %22, i32 8)
%24 = load %struct.wbuf*, %struct.wbuf** %4
%25 = call i32 @wbuf_write(%struct.wbuf* %24, float* getelementptr inbounds ([3 x [3 x float]], [3 x [3 x float]]* @write_fill.q, i64 0, i64 1, i64 0), i32 12)
br label %26
26: ; preds = %12
%27 = load i64, i64* %8
%28 = add i64 %27, 1
store i64 %28, i64* %8
br label %9
29: ; preds = %9
ret void
}

LLVM IR (-O2):
%struct.wbuf = type { i32 }
@write_fill.q = internal constant [3 x [3 x float]] [[3 x float] [float 0.000000e+00, float 0.000000e+00, float 1.000000e+00], [3 x float] [float 0.000000e+00, float 1.000000e+00, float 1.000000e+00], [3 x float] [float 1.000000e+00, float 1.000000e+00, float 1.000000e+00]]
define void @write_fill(%struct.wbuf* %0, i32* nocapture %1, [2 x float]* %2) {
%4 = load i32, i32* %1
%5 = zext i32 %4 to i64
%6 = getelementptr inbounds [2 x float], [2 x float]* %2, i64 %5, i64 0
%7 = tail call i32 @wbuf_write(%struct.wbuf* %0, float* %6, i32 8)
%8 = tail call i32 @wbuf_write(%struct.wbuf* %0, float* getelementptr inbounds ([3 x [3 x float]], [3 x [3 x float]]* @write_fill.q, i64 0, i64 1, i64 0), i32 12)
%9 = getelementptr inbounds i32, i32* %1, i64 1
%10 = load i32, i32* %9
%11 = zext i32 %10 to i64
%12 = getelementptr inbounds [2 x float], [2 x float]* %2, i64 %11, i64 0
%13 = tail call i32 @wbuf_write(%struct.wbuf* %0, float* %12, i32 8)
%14 = tail call i32 @wbuf_write(%struct.wbuf* %0, float* getelementptr inbounds ([3 x [3 x float]], [3 x [3 x float]]* @write_fill.q, i64 0, i64 1, i64 0), i32 12)
%15 = getelementptr inbounds i32, i32* %1, i64 2
%16 = load i32, i32* %15
%17 = zext i32 %16 to i64
%18 = getelementptr inbounds [2 x float], [2 x float]* %2, i64 %17, i64 0
%19 = tail call i32 @wbuf_write(%struct.wbuf* %0, float* %18, i32 8)
%20 = tail call i32 @wbuf_write(%struct.wbuf* %0, float* getelementptr inbounds ([3 x [3 x float]], [3 x [3 x float]]* @write_fill.q, i64 0, i64 1, i64 0), i32 12)
ret void
}