#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*/ bar(float *, float *);
void foo(char *x) {
  float a, b;
  char c[256];
  int i, j;
  bar(&a, &b);
  for (i = 0; i < 256; i++) {
    float v = a;
    if (v < 0.0f)
      v = 0.0f;
    if (v < 255.0f)
      v = 255.0f;
    c[i] = v;
    a += b;
  }
  for (j = 0; j < 256; j++)
    x[j] = c[j];
}


x86 assembly (clang, -O0):
<foo>:
push   %rbp
mov    %rsp,%rbp
sub    $0x120,%rsp
mov    %rdi,-0x8(%rbp)
lea    -0xc(%rbp),%rdi
lea    -0x10(%rbp),%rsi
call   1030 <bar@plt>
movl   $0x0,-0x114(%rbp)
cmpl   $0x100,-0x114(%rbp)
jge    11d2 <foo+0xc2>
movss  -0xc(%rbp),%xmm0
movss  %xmm0,-0x11c(%rbp)
ff
xorps  %xmm0,%xmm0
ucomiss -0x11c(%rbp),%xmm0
jbe    116e <foo+0x5e>
xorps  %xmm0,%xmm0
movss  %xmm0,-0x11c(%rbp)
ff
movss  0xe8a(%rip),%xmm0
ucomiss -0x11c(%rbp),%xmm0
jbe    1193 <foo+0x83>
movss  0xe75(%rip),%xmm0
movss  %xmm0,-0x11c(%rbp)
ff
movss  -0x11c(%rbp),%xmm0
ff
cvttss2si %xmm0,%eax
mov    %al,%cl
movslq -0x114(%rbp),%rax
mov    %cl,-0x110(%rbp,%rax,1)
movss  -0x10(%rbp),%xmm0
addss  -0xc(%rbp),%xmm0
movss  %xmm0,-0xc(%rbp)
mov    -0x114(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x114(%rbp)
jmp    1136 <foo+0x26>
movl   $0x0,-0x118(%rbp)
cmpl   $0x100,-0x118(%rbp)
jge    121c <foo+0x10c>
movslq -0x118(%rbp),%rax
mov    -0x110(%rbp,%rax,1),%dl
mov    -0x8(%rbp),%rax
movslq -0x118(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x118(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x118(%rbp)
jmp    11dc <foo+0xcc>
add    $0x120,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<foo>:
push   %rbx
sub    $0x110,%rsp
mov    %rdi,%rbx
lea    0xc(%rsp),%rdi
lea    0x8(%rsp),%rsi
call   1030 <bar@plt>
movss  0x8(%rsp),%xmm0
xor    %eax,%eax
movss  0xc(%rsp),%xmm1
movss  0xeb0(%rip),%xmm2
xorps  %xmm3,%xmm3
maxss  %xmm1,%xmm3
movaps %xmm2,%xmm4
maxss  %xmm3,%xmm4
cvttss2si %xmm4,%ecx
mov    %cl,0x10(%rsp,%rax,1)
addss  %xmm0,%xmm1
xorps  %xmm3,%xmm3
maxss  %xmm1,%xmm3
movaps %xmm2,%xmm4
maxss  %xmm3,%xmm4
cvttss2si %xmm4,%ecx
mov    %cl,0x11(%rsp,%rax,1)
addss  %xmm0,%xmm1
add    $0x2,%rax
cmp    $0x100,%rax
jne    1150 <foo+0x30>
lea    0x10(%rsp),%rsi
mov    $0x100,%edx
mov    %rbx,%rdi
call   1040 <memcpy@plt>
add    $0x110,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define void @foo(i8* %0) {
%2 = alloca i8*
%3 = alloca float
%4 = alloca float
%5 = alloca [256 x i8]
%6 = alloca i32
%7 = alloca i32
%8 = alloca float
store i8* %0, i8** %2
%9 = call i32 @bar(float* %3, float* %4)
store i32 0, i32* %6
br label %10
10: ; preds = %31, %1
%11 = load i32, i32* %6
%12 = icmp slt i32 %11, 256
br i1 %12, label %13, label %34
13: ; preds = %10
%14 = load float, float* %3
store float %14, float* %8
%15 = load float, float* %8
%16 = fcmp olt float %15, 0.000000e+00
br i1 %16, label %17, label %18
17: ; preds = %13
store float 0.000000e+00, float* %8
br label %18
18: ; preds = %17, %13
%19 = load float, float* %8
%20 = fcmp olt float %19, 2.550000e+02
br i1 %20, label %21, label %22
21: ; preds = %18
store float 2.550000e+02, float* %8
br label %22
22: ; preds = %21, %18
%23 = load float, float* %8
%24 = fptosi float %23 to i8
%25 = load i32, i32* %6
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 %26
store i8 %24, i8* %27
%28 = load float, float* %4
%29 = load float, float* %3
%30 = fadd float %29, %28
store float %30, float* %3
br label %31
31: ; preds = %22
%32 = load i32, i32* %6
%33 = add nsw i32 %32, 1
store i32 %33, i32* %6
br label %10
34: ; preds = %10
store i32 0, i32* %7
br label %35
35: ; preds = %47, %34
%36 = load i32, i32* %7
%37 = icmp slt i32 %36, 256
br i1 %37, label %38, label %50
38: ; preds = %35
%39 = load i32, i32* %7
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 %40
%42 = load i8, i8* %41
%43 = load i8*, i8** %2
%44 = load i32, i32* %7
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds i8, i8* %43, i64 %45
store i8 %42, i8* %46
br label %47
47: ; preds = %38
%48 = load i32, i32* %7
%49 = add nsw i32 %48, 1
store i32 %49, i32* %7
br label %35
50: ; preds = %35
ret void
}

LLVM IR (-O2):
define void @foo(i8* nocapture writeonly %0) {
%2 = alloca float
%3 = alloca float
%4 = alloca [256 x i8]
%5 = bitcast float* %2 to i8*
%6 = bitcast float* %3 to i8*
%7 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 0
%8 = call i32 @bar(float* %2, float* %3)
%9 = load float, float* %3
%10 = load float, float* %2
br label %13
11: ; preds = %13
%12 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 0
ret void
13: ; preds = %13, %1
%14 = phi i64 [ 0, %1 ], [ %31, %13 ]
%15 = phi float [ %10, %1 ], [ %30, %13 ]
%16 = fcmp olt float %15, 0.000000e+00
%17 = select i1 %16, float 0.000000e+00, float %15
%18 = fcmp olt float %17, 2.550000e+02
%19 = select i1 %18, float 2.550000e+02, float %17
%20 = fptosi float %19 to i8
%21 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 %14
store i8 %20, i8* %21
%22 = fadd float %15, %9
%23 = or i64 %14, 1
%24 = fcmp olt float %22, 0.000000e+00
%25 = select i1 %24, float 0.000000e+00, float %22
%26 = fcmp olt float %25, 2.550000e+02
%27 = select i1 %26, float 2.550000e+02, float %25
%28 = fptosi float %27 to i8
%29 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 %23
store i8 %28, i8* %29
%30 = fadd float %22, %9
%31 = add nuw nsw i64 %14, 2
%32 = icmp eq i64 %31, 256
br i1 %32, label %11, label %13
}