#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 */
struct printing_state {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ print_buff_add(struct printing_state *, char const);
void print_string(struct printing_state *ps, const char *c) {
  if (c) {
    while (*c) {
      print_buff_add(ps, *c);
      c++;
    }
  } else {
    print_buff_add(ps, '(');
    print_buff_add(ps, 'n');
    print_buff_add(ps, 'u');
    print_buff_add(ps, 'l');
    print_buff_add(ps, 'l');
    print_buff_add(ps, ')');
  }
}


x86 assembly (clang, -O0):
<print_string>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1163 <print_string+0x53>
jmp    1130 <print_string+0x20>
mov    -0x10(%rbp),%rax
cmpb   $0x0,(%rax)
je     115e <print_string+0x4e>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rax
movsbl (%rax),%esi
call   1030 <print_buff_add@plt>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    1130 <print_string+0x20>
jmp    11b7 <print_string+0xa7>
mov    -0x8(%rbp),%rdi
mov    $0x28,%esi
call   1030 <print_buff_add@plt>
mov    -0x8(%rbp),%rdi
mov    $0x6e,%esi
call   1030 <print_buff_add@plt>
mov    -0x8(%rbp),%rdi
mov    $0x75,%esi
call   1030 <print_buff_add@plt>
mov    -0x8(%rbp),%rdi
mov    $0x6c,%esi
call   1030 <print_buff_add@plt>
mov    -0x8(%rbp),%rdi
mov    $0x6c,%esi
call   1030 <print_buff_add@plt>
mov    -0x8(%rbp),%rdi
mov    $0x29,%esi
call   1030 <print_buff_add@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_string>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
test   %rsi,%rsi
je     114e <print_string+0x3e>
mov    %rsi,%rbx
mov    (%rsi),%al
test   %al,%al
je     1146 <print_string+0x36>
add    $0x1,%rbx
nopl   0x0(%rax)
movsbl %al,%esi
mov    %r14,%rdi
call   1030 <print_buff_add@plt>
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
jne    1130 <print_string+0x20>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
mov    %r14,%rdi
mov    $0x28,%esi
call   1030 <print_buff_add@plt>
mov    %r14,%rdi
mov    $0x6e,%esi
call   1030 <print_buff_add@plt>
mov    %r14,%rdi
mov    $0x75,%esi
call   1030 <print_buff_add@plt>
mov    %r14,%rdi
mov    $0x6c,%esi
call   1030 <print_buff_add@plt>
mov    %r14,%rdi
mov    $0x6c,%esi
call   1030 <print_buff_add@plt>
mov    %r14,%rdi
mov    $0x29,%esi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <print_buff_add@plt>

LLVM IR (-O0):
%struct.printing_state = type { i32 }
define void @print_string(%struct.printing_state* %0, i8* %1) {
%3 = alloca %struct.printing_state*
%4 = alloca i8*
store %struct.printing_state* %0, %struct.printing_state** %3
store i8* %1, i8** %4
%5 = load i8*, i8** %4
%6 = icmp ne i8* %5, null
br i1 %6, label %7, label %20
7: ; preds = %2
br label %8
8: ; preds = %12, %7
%9 = load i8*, i8** %4
%10 = load i8, i8* %9
%11 = icmp ne i8 %10, 0
br i1 %11, label %12, label %19
12: ; preds = %8
%13 = load %struct.printing_state*, %struct.printing_state** %3
%14 = load i8*, i8** %4
%15 = load i8, i8* %14
%16 = call i32 @print_buff_add(%struct.printing_state* %13, i8 signext %15)
%17 = load i8*, i8** %4
%18 = getelementptr inbounds i8, i8* %17, i32 1
store i8* %18, i8** %4
br label %8
19: ; preds = %8
br label %33
20: ; preds = %2
%21 = load %struct.printing_state*, %struct.printing_state** %3
%22 = call i32 @print_buff_add(%struct.printing_state* %21, i8 signext 40)
%23 = load %struct.printing_state*, %struct.printing_state** %3
%24 = call i32 @print_buff_add(%struct.printing_state* %23, i8 signext 110)
%25 = load %struct.printing_state*, %struct.printing_state** %3
%26 = call i32 @print_buff_add(%struct.printing_state* %25, i8 signext 117)
%27 = load %struct.printing_state*, %struct.printing_state** %3
%28 = call i32 @print_buff_add(%struct.printing_state* %27, i8 signext 108)
%29 = load %struct.printing_state*, %struct.printing_state** %3
%30 = call i32 @print_buff_add(%struct.printing_state* %29, i8 signext 108)
%31 = load %struct.printing_state*, %struct.printing_state** %3
%32 = call i32 @print_buff_add(%struct.printing_state* %31, i8 signext 41)
br label %33
33: ; preds = %20, %19
ret void
}

LLVM IR (-O2):
%struct.printing_state = type { i32 }
define void @print_string(%struct.printing_state* %0, i8* %1) {
%3 = icmp eq i8* %1, null
br i1 %3, label %14, label %4
4: ; preds = %2
%5 = load i8, i8* %1
%6 = icmp eq i8 %5, 0
br i1 %6, label %21, label %7
7: ; preds = %4, %7
%8 = phi i8 [ %12, %7 ], [ %5, %4 ]
%9 = phi i8* [ %11, %7 ], [ %1, %4 ]
%10 = tail call i32 @print_buff_add(%struct.printing_state* %0, i8 signext %8)
%11 = getelementptr inbounds i8, i8* %9, i64 1
%12 = load i8, i8* %11
%13 = icmp eq i8 %12, 0
br i1 %13, label %21, label %7
14: ; preds = %2
%15 = tail call i32 @print_buff_add(%struct.printing_state* %0, i8 signext 40)
%16 = tail call i32 @print_buff_add(%struct.printing_state* %0, i8 signext 110)
%17 = tail call i32 @print_buff_add(%struct.printing_state* %0, i8 signext 117)
%18 = tail call i32 @print_buff_add(%struct.printing_state* %0, i8 signext 108)
%19 = tail call i32 @print_buff_add(%struct.printing_state* %0, i8 signext 108)
%20 = tail call i32 @print_buff_add(%struct.printing_state* %0, i8 signext 41)
br label %21
21: ; preds = %7, %4, %14
ret void
}