#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 */
typedef int /*<<< orphan*/ buf;

/* Variables and functions */
int /*<<< orphan*/ Quit(char *);
int /*<<< orphan*/ US_CPrintLine(char *);
int /*<<< orphan*/ strcpy(char *, char const *);
int strlen(char const *);
void US_CPrint(const char *str) {
  char lastChar;
  char *strInLine, *strLineStart;
  char buf[256];
  if (strlen(str) > sizeof(buf) / sizeof(char)) {
    Quit("US_CPrint() - String too long");
  }
  strcpy(buf, str);
  strLineStart = buf;
  while (*strLineStart) {
    strInLine = strLineStart;
    while (*strInLine) {
      if (*strInLine == '\n')
        break;
      strInLine++;
    }
    lastChar = *strInLine;
    *strInLine = '\0';
    US_CPrintLine(strLineStart);
    strLineStart = strInLine;
    if (lastChar) {
      *strInLine = lastChar;
      strLineStart++;
    }
  }
}


x86 assembly (clang, -O0):
<US_CPrint>:
push   %rbp
mov    %rsp,%rbp
sub    $0x120,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <strlen@plt>
cltq
cmp    $0x100,%rax
jbe    1172 <US_CPrint+0x32>
lea    0xe93(%rip),%rdi
call   1060 <Quit@plt>
lea    -0x120(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1030 <strcpy@plt>
lea    -0x120(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
cmpb   $0x0,(%rax)
je     121a <US_CPrint+0xda>
mov    -0x20(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
cmpb   $0x0,(%rax)
je     11d5 <US_CPrint+0x95>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0xa,%eax
jne    11c4 <US_CPrint+0x84>
jmp    11d5 <US_CPrint+0x95>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    11a2 <US_CPrint+0x62>
mov    -0x18(%rbp),%rax
mov    (%rax),%al
mov    %al,-0x9(%rbp)
mov    -0x18(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x20(%rbp),%rdi
call   1040 <US_CPrintLine@plt>
mov    -0x18(%rbp),%rax
mov    %rax,-0x20(%rbp)
cmpb   $0x0,-0x9(%rbp)
je     1215 <US_CPrint+0xd5>
mov    -0x9(%rbp),%cl
mov    -0x18(%rbp),%rax
mov    %cl,(%rax)
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    118d <US_CPrint+0x4d>
add    $0x120,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<US_CPrint>:
push   %r15
push   %r14
push   %rbx
sub    $0x100,%rsp
mov    %rdi,%r14
call   1050 <strlen@plt>
cmp    $0x101,%eax
jb     1167 <US_CPrint+0x27>
lea    0xe9e(%rip),%rdi
call   1060 <Quit@plt>
mov    %rsp,%r15
mov    %r15,%rdi
mov    %r14,%rsi
call   1030 <strcpy@plt>
mov    (%rsp),%bl
test   %bl,%bl
je     11c4 <US_CPrint+0x84>
mov    %r15,%r14
jmp    1199 <US_CPrint+0x59>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movzbl 0x1(%r14),%ebx
add    $0x1,%r14
test   %bl,%bl
je     11a2 <US_CPrint+0x62>
cmp    $0xa,%bl
jne    1190 <US_CPrint+0x50>
movb   $0x0,(%r14)
mov    %r15,%rdi
call   1040 <US_CPrintLine@plt>
test   %bl,%bl
je     11b9 <US_CPrint+0x79>
mov    %bl,(%r14)
add    $0x1,%r14
movzbl (%r14),%ebx
mov    %r14,%r15
test   %bl,%bl
jne    1199 <US_CPrint+0x59>
add    $0x100,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [30 x i8] c"US_CPrint() - String too long\00"
define void @US_CPrint(i8* %0) {
%2 = alloca i8*
%3 = alloca i8
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca [256 x i8]
store i8* %0, i8** %2
%7 = load i8*, i8** %2
%8 = call i32 @strlen(i8* %7)
%9 = sext i32 %8 to i64
%10 = icmp ugt i64 %9, 256
br i1 %10, label %11, label %13
11: ; preds = %1
%12 = call i32 @Quit(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0))
br label %13
13: ; preds = %11, %1
%14 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%15 = load i8*, i8** %2
%16 = call i32 @strcpy(i8* %14, i8* %15)
%17 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
store i8* %17, i8** %5
br label %18
18: ; preds = %51, %13
%19 = load i8*, i8** %5
%20 = load i8, i8* %19
%21 = icmp ne i8 %20, 0
br i1 %21, label %22, label %52
22: ; preds = %18
%23 = load i8*, i8** %5
store i8* %23, i8** %4
br label %24
24: ; preds = %34, %22
%25 = load i8*, i8** %4
%26 = load i8, i8* %25
%27 = icmp ne i8 %26, 0
br i1 %27, label %28, label %37
28: ; preds = %24
%29 = load i8*, i8** %4
%30 = load i8, i8* %29
%31 = sext i8 %30 to i32
%32 = icmp eq i32 %31, 10
br i1 %32, label %33, label %34
33: ; preds = %28
br label %37
34: ; preds = %28
%35 = load i8*, i8** %4
%36 = getelementptr inbounds i8, i8* %35, i32 1
store i8* %36, i8** %4
br label %24
37: ; preds = %33, %24
%38 = load i8*, i8** %4
%39 = load i8, i8* %38
store i8 %39, i8* %3
%40 = load i8*, i8** %4
store i8 0, i8* %40
%41 = load i8*, i8** %5
%42 = call i32 @US_CPrintLine(i8* %41)
%43 = load i8*, i8** %4
store i8* %43, i8** %5
%44 = load i8, i8* %3
%45 = icmp ne i8 %44, 0
br i1 %45, label %46, label %51
46: ; preds = %37
%47 = load i8, i8* %3
%48 = load i8*, i8** %4
store i8 %47, i8* %48
%49 = load i8*, i8** %5
%50 = getelementptr inbounds i8, i8* %49, i32 1
store i8* %50, i8** %5
br label %51
51: ; preds = %46, %37
br label %18
52: ; preds = %18
ret void
}

LLVM IR (-O2):
@.str = [30 x i8] c"US_CPrint() - String too long\00"
define void @US_CPrint(i8* %0) {
%2 = alloca [256 x i8]
%3 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%4 = tail call i32 @strlen(i8* %0)
%5 = icmp ugt i32 %4, 256
br i1 %5, label %6, label %8
6: ; preds = %1
%7 = tail call i32 @Quit(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0))
br label %8
8: ; preds = %6, %1
%9 = call i32 @strcpy(i8* %3, i8* %0)
%10 = load i8, i8* %3
%11 = icmp eq i8 %10, 0
br i1 %11, label %30, label %12
12: ; preds = %8, %26
%13 = phi i8 [ %28, %26 ], [ %10, %8 ]
%14 = phi i8* [ %27, %26 ], [ %3, %8 ]
br label %15
15: ; preds = %12, %18
%16 = phi i8 [ %20, %18 ], [ %13, %12 ]
%17 = phi i8* [ %19, %18 ], [ %14, %12 ]
switch i8 %16, label %18 [
i8 0, label %21
i8 10, label %21
]
18: ; preds = %15
%19 = getelementptr inbounds i8, i8* %17, i64 1
%20 = load i8, i8* %19
br label %15
21: ; preds = %15, %15
store i8 0, i8* %17
%22 = call i32 @US_CPrintLine(i8* %14)
%23 = icmp eq i8 %16, 0
br i1 %23, label %26, label %24
24: ; preds = %21
store i8 %16, i8* %17
%25 = getelementptr inbounds i8, i8* %17, i64 1
br label %26
26: ; preds = %24, %21
%27 = phi i8* [ %25, %24 ], [ %17, %21 ]
%28 = load i8, i8* %27
%29 = icmp eq i8 %28, 0
br i1 %29, label %30, label %12
30: ; preds = %26, %8
ret void
}