#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*/ outc(char);
void puts(char *msg) {
  long i = 0, j = 0;
  char out;
  while (*msg) {
    for (j = 0; j < 1; j++) {
      i = 0;
      while (i < 1000000) {
        i++;
      }
    }
    j = 0;
    out = *msg;
    msg++;
    outc(out);
  }
}


x86 assembly (clang, -O0):
<puts>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movq   $0x0,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
mov    -0x8(%rbp),%rax
cmpb   $0x0,(%rax)
je     11b4 <puts+0xa4>
movq   $0x0,-0x18(%rbp)
cmpq   $0x1,-0x18(%rbp)
jge    1189 <puts+0x79>
movq   $0x0,-0x10(%rbp)
cmpq   $0xf4240,-0x10(%rbp)
jge    1173 <puts+0x63>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    1154 <puts+0x44>
jmp    1178 <puts+0x68>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1141 <puts+0x31>
movq   $0x0,-0x18(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%al
mov    %al,-0x19(%rbp)
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
movsbl -0x19(%rbp),%edi
call   1030 <outc@plt>
jmp    112c <puts+0x1c>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<puts>:
push   %rbx
mov    (%rdi),%al
test   %al,%al
je     1133 <puts+0x23>
mov    %rdi,%rbx
add    $0x1,%rbx
xchg   %ax,%ax
movsbl %al,%edi
call   1030 <outc@plt>
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
jne    1120 <puts+0x10>
pop    %rbx
ret

LLVM IR (-O0):
define void @puts(i8* %0) {
%2 = alloca i8*
%3 = alloca i64
%4 = alloca i64
%5 = alloca i8
store i8* %0, i8** %2
store i64 0, i64* %3
store i64 0, i64* %4
br label %6
6: ; preds = %25, %1
%7 = load i8*, i8** %2
%8 = load i8, i8* %7
%9 = icmp ne i8 %8, 0
br i1 %9, label %10, label %32
10: ; preds = %6
store i64 0, i64* %4
br label %11
11: ; preds = %22, %10
%12 = load i64, i64* %4
%13 = icmp slt i64 %12, 1
br i1 %13, label %14, label %25
14: ; preds = %11
store i64 0, i64* %3
br label %15
15: ; preds = %18, %14
%16 = load i64, i64* %3
%17 = icmp slt i64 %16, 1000000
br i1 %17, label %18, label %21
18: ; preds = %15
%19 = load i64, i64* %3
%20 = add nsw i64 %19, 1
store i64 %20, i64* %3
br label %15
21: ; preds = %15
br label %22
22: ; preds = %21
%23 = load i64, i64* %4
%24 = add nsw i64 %23, 1
store i64 %24, i64* %4
br label %11
25: ; preds = %11
store i64 0, i64* %4
%26 = load i8*, i8** %2
%27 = load i8, i8* %26
store i8 %27, i8* %5
%28 = load i8*, i8** %2
%29 = getelementptr inbounds i8, i8* %28, i32 1
store i8* %29, i8** %2
%30 = load i8, i8* %5
%31 = call i32 @outc(i8 signext %30)
br label %6
32: ; preds = %6
ret void
}

LLVM IR (-O2):
define void @puts(i8* nocapture %0) {
%2 = load i8, i8* %0
%3 = icmp eq i8 %2, 0
br i1 %3, label %11, label %4
4: ; preds = %1, %4
%5 = phi i8 [ %9, %4 ], [ %2, %1 ]
%6 = phi i8* [ %7, %4 ], [ %0, %1 ]
%7 = getelementptr inbounds i8, i8* %6, i64 1
%8 = tail call i32 @outc(i8 signext %5)
%9 = load i8, i8* %7
%10 = icmp eq i8 %9, 0
br i1 %10, label %11, label %4
11: ; preds = %4, %1
ret void
}