#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*/ print(char *, ...);
void print_roots(unsigned n, double x[]) {
  unsigned i;
  print("roots: {");
  for (i = 0; i < n; ++i)
    print(" %f", x[i]);
  print(" }\n");
}


x86 assembly (clang, -O0):
<print_roots>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xeda(%rip),%rdi
mov    $0x0,%al
call   1030 <print@plt>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x4(%rbp),%eax
jae    1168 <print_roots+0x58>
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
movsd  (%rax,%rcx,8),%xmm0
lea    0xeb6(%rip),%rdi
mov    $0x1,%al
call   1030 <print@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1134 <print_roots+0x24>
lea    0xe9e(%rip),%rdi
mov    $0x0,%al
call   1030 <print@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_roots>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r15
mov    %edi,%ebp
lea    0xedd(%rip),%rdi
xor    %eax,%eax
call   1030 <print@plt>
test   %ebp,%ebp
je     1159 <print_roots+0x49>
mov    %ebp,%ebp
xor    %ebx,%ebx
lea    0xed0(%rip),%r14
nopl   0x0(%rax)
movsd  (%r15,%rbx,8),%xmm0
mov    %r14,%rdi
mov    $0x1,%al
call   1030 <print@plt>
add    $0x1,%rbx
cmp    %rbx,%rbp
jne    1140 <print_roots+0x30>
lea    0xead(%rip),%rdi
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <print@plt>

LLVM IR (-O0):
@.str = [9 x i8] c"roots: {\00"
@.str.1 = [4 x i8] c" %f\00"
@.str.2 = [4 x i8] c" }\0A\00"
define void @print_roots(i32 %0, double* %1) {
%3 = alloca i32
%4 = alloca double*
%5 = alloca i32
store i32 %0, i32* %3
store double* %1, double** %4
%6 = call i32 (i8*, ...) @print(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %5
br label %7
7: ; preds = %18, %2
%8 = load i32, i32* %5
%9 = load i32, i32* %3
%10 = icmp ult i32 %8, %9
br i1 %10, label %11, label %21
11: ; preds = %7
%12 = load double*, double** %4
%13 = load i32, i32* %5
%14 = zext i32 %13 to i64
%15 = getelementptr inbounds double, double* %12, i64 %14
%16 = load double, double* %15
%17 = call i32 (i8*, ...) @print(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double %16)
br label %18
18: ; preds = %11
%19 = load i32, i32* %5
%20 = add i32 %19, 1
store i32 %20, i32* %5
br label %7
21: ; preds = %7
%22 = call i32 (i8*, ...) @print(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [9 x i8] c"roots: {\00"
@.str.1 = [4 x i8] c" %f\00"
@.str.2 = [4 x i8] c" }\0A\00"
define void @print_roots(i32 %0, double* nocapture %1) {
%3 = tail call i32 (i8*, ...) @print(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
%4 = icmp eq i32 %0, 0
br i1 %4, label %14, label %5
5: ; preds = %2
%6 = zext i32 %0 to i64
br label %7
7: ; preds = %5, %7
%8 = phi i64 [ 0, %5 ], [ %12, %7 ]
%9 = getelementptr inbounds double, double* %1, i64 %8
%10 = load double, double* %9
%11 = tail call i32 (i8*, ...) @print(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double %10)
%12 = add nuw nsw i64 %8, 1
%13 = icmp eq i64 %12, %6
br i1 %13, label %14, label %7
14: ; preds = %7, %2
%15 = tail call i32 (i8*, ...) @print(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
ret void
}