#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*/ forwd(int);
int /*<<< orphan*/ turnleft(int);
int /*<<< orphan*/ turnright(int);
void sq_koch(int len, int level) {
  if (0 == level) {
    forwd(len);
    return;
  } else {
    sq_koch(len / 4, level - 1);
    turnleft(90);
    sq_koch(len / 4, level - 1);
    turnright(90);
    sq_koch(len / 4, level - 1);
    turnright(90);
    sq_koch(len / 4, level - 1);
    sq_koch(len / 4, level - 1);
    turnleft(90);
    sq_koch(len / 4, level - 1);
    turnleft(90);
    sq_koch(len / 4, level - 1);
    turnright(90);
    sq_koch(len / 4, level - 1);
  }
}


x86 assembly (clang, -O0):
<sq_koch>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
xor    %eax,%eax
cmp    -0x8(%rbp),%eax
jne    1166 <sq_koch+0x26>
mov    -0x4(%rbp),%edi
call   1050 <forwd@plt>
jmp    1262 <sq_koch+0x122>
mov    -0x4(%rbp),%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
mov    %eax,%edi
mov    -0x8(%rbp),%esi
sub    $0x1,%esi
call   1060 <sq_koch@plt>
mov    $0x5a,%edi
call   1030 <turnleft@plt>
mov    -0x4(%rbp),%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
mov    %eax,%edi
mov    -0x8(%rbp),%esi
sub    $0x1,%esi
call   1060 <sq_koch@plt>
mov    $0x5a,%edi
call   1040 <turnright@plt>
mov    -0x4(%rbp),%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
mov    %eax,%edi
mov    -0x8(%rbp),%esi
sub    $0x1,%esi
call   1060 <sq_koch@plt>
mov    $0x5a,%edi
call   1040 <turnright@plt>
mov    -0x4(%rbp),%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
mov    %eax,%edi
mov    -0x8(%rbp),%esi
sub    $0x1,%esi
call   1060 <sq_koch@plt>
mov    -0x4(%rbp),%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
mov    %eax,%edi
mov    -0x8(%rbp),%esi
sub    $0x1,%esi
call   1060 <sq_koch@plt>
mov    $0x5a,%edi
call   1030 <turnleft@plt>
mov    -0x4(%rbp),%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
mov    %eax,%edi
mov    -0x8(%rbp),%esi
sub    $0x1,%esi
call   1060 <sq_koch@plt>
mov    $0x5a,%edi
call   1030 <turnleft@plt>
mov    -0x4(%rbp),%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
mov    %eax,%edi
mov    -0x8(%rbp),%esi
sub    $0x1,%esi
call   1060 <sq_koch@plt>
mov    $0x5a,%edi
call   1040 <turnright@plt>
mov    -0x4(%rbp),%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
mov    %eax,%edi
mov    -0x8(%rbp),%esi
sub    $0x1,%esi
call   1060 <sq_koch@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sq_koch>:
push   %rbp
push   %rbx
push   %rax
test   %esi,%esi
je     11e3 <sq_koch+0xa3>
mov    %esi,%ebx
add    $0xffffffff,%ebx
lea    0x3(%rdi),%ebp
test   %edi,%edi
cmovns %edi,%ebp
sar    $0x2,%ebp
mov    %ebp,%edi
mov    %ebx,%esi
call   1060 <sq_koch@plt>
mov    $0x5a,%edi
call   1030 <turnleft@plt>
mov    %ebp,%edi
mov    %ebx,%esi
call   1060 <sq_koch@plt>
mov    $0x5a,%edi
call   1040 <turnright@plt>
mov    %ebp,%edi
mov    %ebx,%esi
call   1060 <sq_koch@plt>
mov    $0x5a,%edi
call   1040 <turnright@plt>
mov    %ebp,%edi
mov    %ebx,%esi
call   1060 <sq_koch@plt>
mov    %ebp,%edi
mov    %ebx,%esi
call   1060 <sq_koch@plt>
mov    $0x5a,%edi
call   1030 <turnleft@plt>
mov    %ebp,%edi
mov    %ebx,%esi
call   1060 <sq_koch@plt>
mov    $0x5a,%edi
call   1030 <turnleft@plt>
mov    %ebp,%edi
mov    %ebx,%esi
call   1060 <sq_koch@plt>
mov    $0x5a,%edi
call   1040 <turnright@plt>
mov    %ebp,%edi
add    $0xffffffff,%ebx
jb     1150 <sq_koch+0x10>
jmp    11e5 <sq_koch+0xa5>
mov    %edi,%ebp
mov    %ebp,%edi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1050 <forwd@plt>

LLVM IR (-O0):
define void @sq_koch(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
%5 = load i32, i32* %4
%6 = icmp eq i32 0, %5
br i1 %6, label %7, label %10
7: ; preds = %2
%8 = load i32, i32* %3
%9 = call i32 @forwd(i32 %8)
br label %49
10: ; preds = %2
%11 = load i32, i32* %3
%12 = sdiv i32 %11, 4
%13 = load i32, i32* %4
%14 = sub nsw i32 %13, 1
%15 = call i32 @turnleft(i32 90)
%16 = load i32, i32* %3
%17 = sdiv i32 %16, 4
%18 = load i32, i32* %4
%19 = sub nsw i32 %18, 1
%20 = call i32 @turnright(i32 90)
%21 = load i32, i32* %3
%22 = sdiv i32 %21, 4
%23 = load i32, i32* %4
%24 = sub nsw i32 %23, 1
%25 = call i32 @turnright(i32 90)
%26 = load i32, i32* %3
%27 = sdiv i32 %26, 4
%28 = load i32, i32* %4
%29 = sub nsw i32 %28, 1
%30 = load i32, i32* %3
%31 = sdiv i32 %30, 4
%32 = load i32, i32* %4
%33 = sub nsw i32 %32, 1
%34 = call i32 @turnleft(i32 90)
%35 = load i32, i32* %3
%36 = sdiv i32 %35, 4
%37 = load i32, i32* %4
%38 = sub nsw i32 %37, 1
%39 = call i32 @turnleft(i32 90)
%40 = load i32, i32* %3
%41 = sdiv i32 %40, 4
%42 = load i32, i32* %4
%43 = sub nsw i32 %42, 1
%44 = call i32 @turnright(i32 90)
%45 = load i32, i32* %3
%46 = sdiv i32 %45, 4
%47 = load i32, i32* %4
%48 = sub nsw i32 %47, 1
br label %49
49: ; preds = %7, %10
ret void
}

LLVM IR (-O2):
define void @sq_koch(i32 %0, i32 %1) {
%3 = icmp eq i32 %1, 0
br i1 %3, label %4, label %7
4: ; preds = %7, %2
%5 = phi i32 [ %0, %2 ], [ %10, %7 ]
%6 = tail call i32 @forwd(i32 %5)
ret void
7: ; preds = %2, %7
%8 = phi i32 [ %11, %7 ], [ %1, %2 ]
%9 = phi i32 [ %10, %7 ], [ %0, %2 ]
%10 = sdiv i32 %9, 4
%11 = add nsw i32 %8, -1
tail call void @sq_koch(i32 %10, i32 %11)
%12 = tail call i32 @turnleft(i32 90)
tail call void @sq_koch(i32 %10, i32 %11)
%13 = tail call i32 @turnright(i32 90)
tail call void @sq_koch(i32 %10, i32 %11)
%14 = tail call i32 @turnright(i32 90)
tail call void @sq_koch(i32 %10, i32 %11)
tail call void @sq_koch(i32 %10, i32 %11)
%15 = tail call i32 @turnleft(i32 90)
tail call void @sq_koch(i32 %10, i32 %11)
%16 = tail call i32 @turnleft(i32 90)
tail call void @sq_koch(i32 %10, i32 %11)
%17 = tail call i32 @turnright(i32 90)
%18 = icmp eq i32 %11, 0
br i1 %18, label %4, label %7
}