#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*/ init_console();
int /*<<< orphan*/ printf(char *, ...);
int sinf(float);
int /*<<< orphan*/ space(int);
int main(int argc, char *argv[]) {
  float x;
  argc;
  argv;
  init_console();
  printf("Hello Z80 C world! int %d string %s hex %x\r\n\r\n", 1, "haha", 0xff);
  x = 0;
  do {
    space((int)(40 + sinf(x) * 20));
    printf("*\r\n");
    x += 0.2;
  } while (x <= 6.2);
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x0,%al
call   1060 <init_console@plt>
lea    0xeac(%rip),%rdi
mov    $0x1,%esi
lea    0xecf(%rip),%rdx
mov    $0xff,%ecx
mov    $0x0,%al
call   1050 <printf@plt>
xorps  %xmm0,%xmm0
movss  %xmm0,-0x14(%rbp)
movss  -0x14(%rbp),%xmm0
call   1040 <sinf@plt>
imul   $0x14,%eax,%edi
add    $0x28,%edi
call   1030 <space@plt>
lea    0xea4(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movss  -0x14(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xe48(%rip),%xmm1
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x14(%rbp)
movss  -0x14(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
movsd  0xe32(%rip),%xmm0
ucomisd %xmm1,%xmm0
jae    1184 <main+0x44>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
xor    %eax,%eax
call   1070 <init_console@plt>
lea    0xead(%rip),%rdi
lea    0xed5(%rip),%rdx
mov    $0x1,%esi
mov    $0xff,%ecx
xor    %eax,%eax
call   1060 <printf@plt>
xorps  %xmm0,%xmm0
lea    0xebf(%rip),%rbx
cs nopw 0x0(%rax,%rax,1)
nop
movss  %xmm0,0xc(%rsp)
call   1040 <sinf@plt>
lea    (%rax,%rax,4),%eax
lea    0x28(,%rax,4),%edi
call   1030 <space@plt>
mov    %rbx,%rdi
call   1050 <puts@plt>
movss  0xc(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
addsd  0xe3c(%rip),%xmm0
cvtsd2ss %xmm0,%xmm0
xorps  %xmm2,%xmm2
cvtss2sd %xmm0,%xmm2
movsd  0xe31(%rip),%xmm1
ucomisd %xmm2,%xmm1
jae    1190 <main+0x40>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [47 x i8] c"Hello Z80 C world! int %d string %s hex %x\0D\0A\0D\0A\00"
@.str.1 = [5 x i8] c"haha\00"
@.str.2 = [4 x i8] c"*\0D\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca float
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = load i32, i32* %4
%8 = load i8**, i8*** %5
%9 = call i32 (...) @init_console()
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str, i64 0, i64 0), i32 1, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 255)
store float 0.000000e+00, float* %6
br label %11
11: ; preds = %22, %2
%12 = load float, float* %6
%13 = call i32 @sinf(float %12)
%14 = mul nsw i32 %13, 20
%15 = add nsw i32 40, %14
%16 = call i32 @space(i32 %15)
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%18 = load float, float* %6
%19 = fpext float %18 to double
%20 = fadd double %19, 2.000000e-01
%21 = fptrunc double %20 to float
store float %21, float* %6
br label %22
22: ; preds = %11
%23 = load float, float* %6
%24 = fpext float %23 to double
%25 = fcmp ole double %24, 6.200000e+00
br i1 %25, label %11, label %26
26: ; preds = %22
ret i32 0
}

LLVM IR (-O2):
@.str = [47 x i8] c"Hello Z80 C world! int %d string %s hex %x\0D\0A\0D\0A\00"
@.str.1 = [5 x i8] c"haha\00"
@str = [3 x i8] c"*\0D\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i32 (...) @init_console()
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([47 x i8], [47 x i8]* @.str, i64 0, i64 0), i32 1, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 255)
br label %5
5: ; preds = %5, %2
%6 = phi float [ 0.000000e+00, %2 ], [ %14, %5 ]
%7 = tail call i32 @sinf(float %6)
%8 = mul nsw i32 %7, 20
%9 = add nsw i32 %8, 40
%10 = tail call i32 @space(i32 %9)
%11 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @str, i64 0, i64 0))
%12 = fpext float %6 to double
%13 = fadd double %12, 2.000000e-01
%14 = fptrunc double %13 to float
%15 = fpext float %14 to double
%16 = fcmp ugt double %15, 6.200000e+00
br i1 %16, label %17, label %5
17: ; preds = %5
ret i32 0
}