#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*/ write(int, char const *, int);
int ft_int_putstr(char const *s) {
  int i;
  i = 0;
  if (s == NULL)
    write(1, "(null)", 7);
  else {
    while (s[i])
      i++;
    write(1, s, i);
  }
  return (1);
}


x86 assembly (clang, -O0):
<ft_int_putstr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
cmpq   $0x0,-0x8(%rbp)
jne    1149 <ft_int_putstr+0x39>
mov    $0x1,%edi
lea    0xec6(%rip),%rsi
mov    $0x7,%edx
call   1030 <write@plt>
jmp    117f <ft_int_putstr+0x6f>
jmp    114e <ft_int_putstr+0x3e>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
cmpb   $0x0,(%rax,%rcx,1)
je     116e <ft_int_putstr+0x5e>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    114e <ft_int_putstr+0x3e>
mov    -0x8(%rbp),%rsi
mov    -0xc(%rbp),%edx
mov    $0x1,%edi
call   1030 <write@plt>
mov    $0x1,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ft_int_putstr>:
push   %rax
test   %rdi,%rdi
je     1134 <ft_int_putstr+0x24>
mov    %rdi,%rsi
xor    %edx,%edx
nopl   0x0(%rax,%rax,1)
cmpb   $0x0,(%rsi,%rdx,1)
lea    0x1(%rdx),%rdx
jne    1120 <ft_int_putstr+0x10>
add    $0xffffffff,%edx
mov    $0x1,%edi
jmp    1145 <ft_int_putstr+0x35>
lea    0xec5(%rip),%rsi
mov    $0x1,%edi
mov    $0x7,%edx
call   1030 <write@plt>
mov    $0x1,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [7 x i8] c"(null)\00"
define i32 @ft_int_putstr(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
store i8* %0, i8** %2
store i32 0, i32* %3
%4 = load i8*, i8** %2
%5 = icmp eq i8* %4, null
br i1 %5, label %6, label %8
6: ; preds = %1
%7 = call i32 @write(i32 1, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 7)
br label %23
8: ; preds = %1
br label %9
9: ; preds = %16, %8
%10 = load i8*, i8** %2
%11 = load i32, i32* %3
%12 = sext i32 %11 to i64
%13 = getelementptr inbounds i8, i8* %10, i64 %12
%14 = load i8, i8* %13
%15 = icmp ne i8 %14, 0
br i1 %15, label %16, label %19
16: ; preds = %9
%17 = load i32, i32* %3
%18 = add nsw i32 %17, 1
store i32 %18, i32* %3
br label %9
19: ; preds = %9
%20 = load i8*, i8** %2
%21 = load i32, i32* %3
%22 = call i32 @write(i32 1, i8* %20, i32 %21)
br label %23
23: ; preds = %19, %6
ret i32 1
}

LLVM IR (-O2):
@.str = [7 x i8] c"(null)\00"
define i32 @ft_int_putstr(i8* %0) {
%2 = icmp eq i8* %0, null
br i1 %2, label %3, label %5
3: ; preds = %1
%4 = tail call i32 @write(i32 1, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 7)
br label %14
5: ; preds = %1, %5
%6 = phi i64 [ %10, %5 ], [ 0, %1 ]
%7 = getelementptr inbounds i8, i8* %0, i64 %6
%8 = load i8, i8* %7
%9 = icmp eq i8 %8, 0
%10 = add nuw i64 %6, 1
br i1 %9, label %11, label %5
11: ; preds = %5
%12 = trunc i64 %6 to i32
%13 = tail call i32 @write(i32 1, i8* %0, i32 %12)
br label %14
14: ; preds = %11, %3
ret i32 1
}