#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__ isprint(unsigned char);
scalar_t__ isspace(unsigned char);
int /*<<< orphan*/ putchar(char const);
int _ctype(void) {
  char const str[] = "Hello, world!\n";
  size_t i;
  for (i = 0; str[i] != '\0'; i++)
    if (isprint((unsigned char)str[i]) || isspace((unsigned char)str[i]))
      putchar(str[i]);
  return 0;
}


x86 assembly (clang, -O0):
<_ctype>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    0xec1(%rip),%rax
mov    %rax,-0xf(%rbp)
mov    0xebf(%rip),%eax
mov    %eax,-0x7(%rbp)
mov    0xeb9(%rip),%ax
mov    %ax,-0x3(%rbp)
mov    0xeb1(%rip),%al
mov    %al,-0x1(%rbp)
movq   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%rax
movsbl -0xf(%rbp,%rax,1),%eax
cmp    $0x0,%eax
je     11ce <_ctype+0x9e>
mov    -0x18(%rbp),%rax
movzbl -0xf(%rbp,%rax,1),%edi
call   1050 <isprint@plt>
cmp    $0x0,%rax
jne    11aa <_ctype+0x7a>
mov    -0x18(%rbp),%rax
movzbl -0xf(%rbp,%rax,1),%edi
call   1040 <isspace@plt>
cmp    $0x0,%rax
je     11b8 <_ctype+0x88>
mov    -0x18(%rbp),%rax
movsbl -0xf(%rbp,%rax,1),%edi
call   1030 <putchar@plt>
jmp    11bd <_ctype+0x8d>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1168 <_ctype+0x38>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_ctype>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
xor    %ebx,%ebx
lea    0xec0(%rip),%r14
jmp    1163 <_ctype+0x33>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movsbl %r15b,%edi
call   1030 <putchar@plt>
add    $0x1,%rbx
cmp    $0xe,%rbx
je     1186 <_ctype+0x56>
movzbl (%rbx,%r14,1),%r15d
movzbl %r15b,%ebp
mov    %ebp,%edi
call   1050 <isprint@plt>
test   %rax,%rax
jne    1150 <_ctype+0x20>
mov    %ebp,%edi
call   1040 <isspace@plt>
test   %rax,%rax
jne    1150 <_ctype+0x20>
jmp    1159 <_ctype+0x29>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@__const._ctype.str = [15 x i8] c"Hello, world!\0A\00"
define i32 @_ctype() {
%1 = alloca [15 x i8]
%2 = alloca i64
%3 = bitcast [15 x i8]* %1 to i8*
store i64 0, i64* %2
br label %4
4: ; preds = %28, %0
%5 = load i64, i64* %2
%6 = getelementptr inbounds [15 x i8], [15 x i8]* %1, i64 0, i64 %5
%7 = load i8, i8* %6
%8 = sext i8 %7 to i32
%9 = icmp ne i32 %8, 0
br i1 %9, label %10, label %31
10: ; preds = %4
%11 = load i64, i64* %2
%12 = getelementptr inbounds [15 x i8], [15 x i8]* %1, i64 0, i64 %11
%13 = load i8, i8* %12
%14 = call i64 @isprint(i8 zeroext %13)
%15 = icmp ne i64 %14, 0
br i1 %15, label %22, label %16
16: ; preds = %10
%17 = load i64, i64* %2
%18 = getelementptr inbounds [15 x i8], [15 x i8]* %1, i64 0, i64 %17
%19 = load i8, i8* %18
%20 = call i64 @isspace(i8 zeroext %19)
%21 = icmp ne i64 %20, 0
br i1 %21, label %22, label %27
22: ; preds = %16, %10
%23 = load i64, i64* %2
%24 = getelementptr inbounds [15 x i8], [15 x i8]* %1, i64 0, i64 %23
%25 = load i8, i8* %24
%26 = call i32 @putchar(i8 signext %25)
br label %27
27: ; preds = %22, %16
br label %28
28: ; preds = %27
%29 = load i64, i64* %2
%30 = add i64 %29, 1
store i64 %30, i64* %2
br label %4
31: ; preds = %4
ret i32 0
}

LLVM IR (-O2):
@__const._ctype.str = [15 x i8] c"Hello, world!\0A\00"
define i32 @_ctype() {
br label %1
1: ; preds = %0, %12
%2 = phi i64 [ 0, %0 ], [ %13, %12 ]
%3 = getelementptr inbounds [15 x i8], [15 x i8]* @__const._ctype.str, i64 0, i64 %2
%4 = load i8, i8* %3
%5 = tail call i64 @isprint(i8 zeroext %4)
%6 = icmp eq i64 %5, 0
br i1 %6, label %7, label %10
7: ; preds = %1
%8 = tail call i64 @isspace(i8 zeroext %4)
%9 = icmp eq i64 %8, 0
br i1 %9, label %12, label %10
10: ; preds = %7, %1
%11 = tail call i32 @putchar(i8 signext %4)
br label %12
12: ; preds = %7, %10
%13 = add nuw nsw i64 %2, 1
%14 = icmp eq i64 %13, 14
br i1 %14, label %15, label %1
15: ; preds = %12
ret i32 0
}