#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*/ GL_LINES;
int /*<<< orphan*/ glBegin(int /*<<< orphan*/);
int /*<<< orphan*/ glEnd();
int /*<<< orphan*/ glPopMatrix();
int /*<<< orphan*/ glPushMatrix();
int /*<<< orphan*/ glTranslated(double, double, double);
int /*<<< orphan*/ glVertex3d(double, int, double);
void trava(double d, int n) {
  double s = d / n;
  int i;
  glPushMatrix();
  glTranslated(-d / 2.0, -d / 2.0, 0.0);
  for (i = 0; i <= n; i++) {
    glBegin(GL_LINES);
    glVertex3d(i * s, 0.0, 0.0);
    glVertex3d(i * s, d, 0.0);
    glVertex3d(0.0, i * s, 0.0);
    glVertex3d(d, i * s, 0.0);
    glEnd();
  }
  glPopMatrix();
}


x86 assembly (clang, -O0):
<trava>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movsd  %xmm0,-0x8(%rbp)
mov    %edi,-0xc(%rbp)
movsd  -0x8(%rbp),%xmm0
cvtsi2sdl -0xc(%rbp),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
mov    $0x0,%al
call   1060 <glPushMatrix@plt>
movsd  -0x8(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  0xe52(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  -0x8(%rbp),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
movsd  0xe2a(%rip),%xmm2
divsd  %xmm2,%xmm1
xorps  %xmm2,%xmm2
call   1070 <glTranslated@plt>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jg     1277 <trava+0x117>
mov    0x2df4(%rip),%rax
mov    (%rax),%edi
call   1080 <glBegin@plt>
cvtsi2sdl -0x1c(%rbp),%xmm0
mulsd  -0x18(%rbp),%xmm0
xor    %edi,%edi
xorps  %xmm1,%xmm1
call   1030 <glVertex3d@plt>
cvtsi2sdl -0x1c(%rbp),%xmm0
mulsd  -0x18(%rbp),%xmm0
cvttsd2si -0x8(%rbp),%edi
xorps  %xmm1,%xmm1
call   1030 <glVertex3d@plt>
cvtsi2sdl -0x1c(%rbp),%xmm0
mulsd  -0x18(%rbp),%xmm0
cvttsd2si %xmm0,%edi
xorps  %xmm1,%xmm1
movaps %xmm1,%xmm0
call   1030 <glVertex3d@plt>
movsd  -0x8(%rbp),%xmm0
cvtsi2sdl -0x1c(%rbp),%xmm1
mulsd  -0x18(%rbp),%xmm1
cvttsd2si %xmm1,%edi
xorps  %xmm1,%xmm1
call   1030 <glVertex3d@plt>
mov    $0x0,%al
call   1040 <glEnd@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11e9 <trava+0x89>
mov    $0x0,%al
call   1050 <glPopMatrix@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<trava>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x20,%rsp
mov    %edi,%r14d
movsd  %xmm0,0x8(%rsp)
xor    %eax,%eax
call   1060 <glPushMatrix@plt>
movsd  0xe7c(%rip),%xmm0
mulsd  0x8(%rsp),%xmm0
xorpd  %xmm2,%xmm2
movapd %xmm0,%xmm1
call   1070 <glTranslated@plt>
test   %r14d,%r14d
js     123c <trava+0xdc>
xorps  %xmm0,%xmm0
cvtsi2sd %r14d,%xmm0
movsd  0x8(%rsp),%xmm1
movapd %xmm1,%xmm2
cvttsd2si %xmm1,%r12d
divsd  %xmm0,%xmm2
movsd  %xmm2,0x18(%rsp)
add    $0x1,%r14d
mov    0x2e24(%rip),%r15
xor    %ebp,%ebp
xchg   %ax,%ax
mov    (%r15),%edi
call   1080 <glBegin@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %ebp,%xmm0
mulsd  0x18(%rsp),%xmm0
movsd  %xmm0,0x10(%rsp)
xorpd  %xmm1,%xmm1
xor    %edi,%edi
call   1030 <glVertex3d@plt>
xorpd  %xmm1,%xmm1
movsd  0x10(%rsp),%xmm0
mov    %r12d,%edi
call   1030 <glVertex3d@plt>
cvttsd2si 0x10(%rsp),%ebx
xorps  %xmm0,%xmm0
xorpd  %xmm1,%xmm1
mov    %ebx,%edi
call   1030 <glVertex3d@plt>
xorpd  %xmm1,%xmm1
movsd  0x8(%rsp),%xmm0
mov    %ebx,%edi
call   1030 <glVertex3d@plt>
xor    %eax,%eax
call   1040 <glEnd@plt>
add    $0x1,%ebp
cmp    %ebp,%r14d
jne    11d0 <trava+0x70>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1050 <glPopMatrix@plt>

LLVM IR (-O0):
@GL_LINES = global i32 0
define void @trava(double %0, i32 %1) {
%3 = alloca double
%4 = alloca i32
%5 = alloca double
%6 = alloca i32
store double %0, double* %3
store i32 %1, i32* %4
%7 = load double, double* %3
%8 = load i32, i32* %4
%9 = sitofp i32 %8 to double
%10 = fdiv double %7, %9
store double %10, double* %5
%11 = call i32 (...) @glPushMatrix()
%12 = load double, double* %3
%13 = fneg double %12
%14 = fdiv double %13, 2.000000e+00
%15 = load double, double* %3
%16 = fneg double %15
%17 = fdiv double %16, 2.000000e+00
%18 = call i32 @glTranslated(double %14, double %17, double 0.000000e+00)
store i32 0, i32* %6
br label %19
19: ; preds = %52, %2
%20 = load i32, i32* %6
%21 = load i32, i32* %4
%22 = icmp sle i32 %20, %21
br i1 %22, label %23, label %55
23: ; preds = %19
%24 = load i32, i32* @GL_LINES
%25 = call i32 @glBegin(i32 %24)
%26 = load i32, i32* %6
%27 = sitofp i32 %26 to double
%28 = load double, double* %5
%29 = fmul double %27, %28
%30 = call i32 @glVertex3d(double %29, i32 0, double 0.000000e+00)
%31 = load i32, i32* %6
%32 = sitofp i32 %31 to double
%33 = load double, double* %5
%34 = fmul double %32, %33
%35 = load double, double* %3
%36 = fptosi double %35 to i32
%37 = call i32 @glVertex3d(double %34, i32 %36, double 0.000000e+00)
%38 = load i32, i32* %6
%39 = sitofp i32 %38 to double
%40 = load double, double* %5
%41 = fmul double %39, %40
%42 = fptosi double %41 to i32
%43 = call i32 @glVertex3d(double 0.000000e+00, i32 %42, double 0.000000e+00)
%44 = load double, double* %3
%45 = load i32, i32* %6
%46 = sitofp i32 %45 to double
%47 = load double, double* %5
%48 = fmul double %46, %47
%49 = fptosi double %48 to i32
%50 = call i32 @glVertex3d(double %44, i32 %49, double 0.000000e+00)
%51 = call i32 (...) @glEnd()
br label %52
52: ; preds = %23
%53 = load i32, i32* %6
%54 = add nsw i32 %53, 1
store i32 %54, i32* %6
br label %19
55: ; preds = %19
%56 = call i32 (...) @glPopMatrix()
ret void
}

LLVM IR (-O2):
@GL_LINES = global i32 0
define void @trava(double %0, i32 %1) {
%3 = sitofp i32 %1 to double
%4 = fdiv double %0, %3
%5 = tail call i32 (...) @glPushMatrix()
%6 = fmul double %0, -5.000000e-01
%7 = tail call i32 @glTranslated(double %6, double %6, double 0.000000e+00)
%8 = icmp slt i32 %1, 0
br i1 %8, label %25, label %9
9: ; preds = %2
%10 = fptosi double %0 to i32
br label %11
11: ; preds = %9, %11
%12 = phi i32 [ 0, %9 ], [ %23, %11 ]
%13 = load i32, i32* @GL_LINES
%14 = tail call i32 @glBegin(i32 %13)
%15 = sitofp i32 %12 to double
%16 = fmul double %4, %15
%17 = tail call i32 @glVertex3d(double %16, i32 0, double 0.000000e+00)
%18 = tail call i32 @glVertex3d(double %16, i32 %10, double 0.000000e+00)
%19 = fptosi double %16 to i32
%20 = tail call i32 @glVertex3d(double 0.000000e+00, i32 %19, double 0.000000e+00)
%21 = tail call i32 @glVertex3d(double %0, i32 %19, double 0.000000e+00)
%22 = tail call i32 (...) @glEnd()
%23 = add nuw i32 %12, 1
%24 = icmp eq i32 %12, %1
br i1 %24, label %25, label %11
25: ; preds = %11, %2
%26 = tail call i32 (...) @glPopMatrix()
ret void
}