#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 */
scalar_t__ ft_is_prime(int);
int /*<<< orphan*/ ft_putnbr(int);
void add_prime_sum(int nbr) {
  int i;
  int sum;
  i = 2;
  sum = 0;
  while (i <= nbr) {
    if (ft_is_prime(i)) {
      sum = sum + i;
      i++;
    } else
      i++;
  }
  ft_putnbr(sum);
}


x86 assembly (clang, -O0):
<add_prime_sum>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x2,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0x4(%rbp),%eax
jg     117c <add_prime_sum+0x5c>
mov    -0x8(%rbp),%edi
call   1030 <ft_is_prime@plt>
cmp    $0x0,%rax
je     116e <add_prime_sum+0x4e>
mov    -0xc(%rbp),%eax
add    -0x8(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1177 <add_prime_sum+0x57>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1139 <add_prime_sum+0x19>
mov    -0xc(%rbp),%edi
call   1040 <ft_putnbr@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<add_prime_sum>:
push   %rbp
push   %r14
push   %rbx
xor    %ebp,%ebp
cmp    $0x2,%edi
jge    1136 <add_prime_sum+0x16>
mov    %ebp,%edi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1040 <ft_putnbr@plt>
mov    %edi,%r14d
neg    %r14d
mov    $0x2,%ebx
xor    %ebp,%ebp
jmp    1165 <add_prime_sum+0x45>
cs nopw 0x0(%rax,%rax,1)
nop
add    %ecx,%ebp
lea    (%r14,%rbx,1),%eax
add    $0x1,%eax
mov    %ebx,%ecx
add    $0x1,%ecx
mov    %ecx,%ebx
cmp    $0x1,%eax
je     112b <add_prime_sum+0xb>
mov    %ebx,%edi
call   1030 <ft_is_prime@plt>
mov    $0x0,%ecx
test   %rax,%rax
je     1150 <add_prime_sum+0x30>
mov    %ebx,%ecx
jmp    1150 <add_prime_sum+0x30>

LLVM IR (-O0):
define void @add_prime_sum(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 %0, i32* %2
store i32 2, i32* %3
store i32 0, i32* %4
br label %5
5: ; preds = %22, %1
%6 = load i32, i32* %3
%7 = load i32, i32* %2
%8 = icmp sle i32 %6, %7
br i1 %8, label %9, label %23
9: ; preds = %5
%10 = load i32, i32* %3
%11 = call i64 @ft_is_prime(i32 %10)
%12 = icmp ne i64 %11, 0
br i1 %12, label %13, label %19
13: ; preds = %9
%14 = load i32, i32* %4
%15 = load i32, i32* %3
%16 = add nsw i32 %14, %15
store i32 %16, i32* %4
%17 = load i32, i32* %3
%18 = add nsw i32 %17, 1
store i32 %18, i32* %3
br label %22
19: ; preds = %9
%20 = load i32, i32* %3
%21 = add nsw i32 %20, 1
store i32 %21, i32* %3
br label %22
22: ; preds = %19, %13
br label %5
23: ; preds = %5
%24 = load i32, i32* %4
%25 = call i32 @ft_putnbr(i32 %24)
ret void
}

LLVM IR (-O2):
define void @add_prime_sum(i32 %0) {
%2 = icmp slt i32 %0, 2
br i1 %2, label %12, label %3
3: ; preds = %1, %3
%4 = phi i32 [ %9, %3 ], [ 0, %1 ]
%5 = phi i32 [ %10, %3 ], [ 2, %1 ]
%6 = tail call i64 @ft_is_prime(i32 %5)
%7 = icmp eq i64 %6, 0
%8 = select i1 %7, i32 0, i32 %5
%9 = add nuw nsw i32 %8, %4
%10 = add nuw i32 %5, 1
%11 = icmp eq i32 %5, %0
br i1 %11, label %12, label %3
12: ; preds = %3, %1
%13 = phi i32 [ 0, %1 ], [ %9, %3 ]
%14 = tail call i32 @ft_putnbr(i32 %13)
ret void
}