#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__ islower(char);
int /*<<< orphan*/ memset(char *, char, int);
int /*<<< orphan*/ read(int, char *, int);
scalar_t__ strcmp(char *, char *);
int strlen(char *);
int /*<<< orphan*/ write(int, char *, int);
void *runner(void *args) {
  int i, sfd = *(int *)args;
  char buf[128];
  while (1) {
    memset(buf, '\0', 128);
    read(sfd, buf, 128);
    if (strcmp(buf, "exit") == 0)
      break;
    for (i = 0; i < strlen(buf); ++i) {
      if (islower(buf[i]))
        buf[i] = buf[i] - 32;
    }
    write(sfd, buf, strlen(buf));
  }
}


x86 assembly (clang, -O0):
<runner>:
push   %rbp
mov    %rsp,%rbp
sub    $0xc0,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x18(%rbp)
lea    -0xa0(%rbp),%rdi
xor    %esi,%esi
mov    $0x80,%edx
call   1060 <memset@plt>
mov    -0x18(%rbp),%edi
lea    -0xa0(%rbp),%rsi
mov    $0x80,%edx
call   1070 <read@plt>
lea    -0xa0(%rbp),%rdi
lea    0xe53(%rip),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%rax
jne    11c1 <runner+0x61>
jmp    1273 <runner+0x113>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0xa4(%rbp)
lea    -0xa0(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,%ecx
mov    -0xa4(%rbp),%eax
cmp    %ecx,%eax
jge    1237 <runner+0xd7>
movslq -0x14(%rbp),%rax
movsbl -0xa0(%rbp,%rax,1),%edi
ff
call   1030 <islower@plt>
cmp    $0x0,%rax
je     1224 <runner+0xc4>
movslq -0x14(%rbp),%rax
movsbl -0xa0(%rbp,%rax,1),%eax
ff
sub    $0x20,%eax
mov    %al,%cl
movslq -0x14(%rbp),%rax
mov    %cl,-0xa0(%rbp,%rax,1)
jmp    1229 <runner+0xc9>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11c8 <runner+0x68>
mov    -0x18(%rbp),%eax
mov    %eax,-0xb4(%rbp)
lea    -0xa0(%rbp),%rax
mov    %rax,-0xb0(%rbp)
lea    -0xa0(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0xb4(%rbp),%edi
mov    -0xb0(%rbp),%rsi
mov    %eax,%edx
call   1040 <write@plt>
jmp    1178 <runner+0x18>
mov    -0x8(%rbp),%rax
add    $0xc0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<runner>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x88,%rsp
mov    (%rdi),%r15d
mov    %rsp,%rbx
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x80,%edx
call   1060 <memset@plt>
mov    %r15d,%edi
mov    %rbx,%rsi
mov    $0x80,%edx
call   1070 <read@plt>
lea    0xe67(%rip),%rsi
mov    %rbx,%rdi
call   1080 <strcmp@plt>
test   %rax,%rax
je     1247 <runner+0xe7>
mov    %rsp,%rbx
lea    0xe4c(%rip),%r14
jmp    1204 <runner+0xa4>
cs nopw 0x0(%rax,%rax,1)
mov    %rbx,%rdi
call   1050 <strlen@plt>
mov    %r15d,%edi
mov    %rbx,%rsi
mov    %eax,%edx
call   1040 <write@plt>
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x80,%edx
call   1060 <memset@plt>
mov    %r15d,%edi
mov    %rbx,%rsi
mov    $0x80,%edx
call   1070 <read@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1080 <strcmp@plt>
test   %rax,%rax
je     1247 <runner+0xe7>
mov    %rbx,%rdi
call   1050 <strlen@plt>
test   %eax,%eax
jle    11c0 <runner+0x60>
xor    %ebp,%ebp
jmp    1233 <runner+0xd3>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
add    $0x1,%rbp
mov    %rbx,%rdi
call   1050 <strlen@plt>
cltq
cmp    %rax,%rbp
jge    11c0 <runner+0x60>
movsbl (%rsp,%rbp,1),%edi
call   1030 <islower@plt>
test   %rax,%rax
je     1220 <runner+0xc0>
addb   $0xe0,(%rsp,%rbp,1)
jmp    1220 <runner+0xc0>
add    $0x88,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [5 x i8] c"exit\00"
define i8* @runner(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
%6 = alloca [128 x i8]
store i8* %0, i8** %3
%7 = load i8*, i8** %3
%8 = bitcast i8* %7 to i32*
%9 = load i32, i32* %8
store i32 %9, i32* %5
br label %10
10: ; preds = %1, %48
%11 = getelementptr inbounds [128 x i8], [128 x i8]* %6, i64 0, i64 0
%12 = call i32 @memset(i8* %11, i8 signext 0, i32 128)
%13 = load i32, i32* %5
%14 = getelementptr inbounds [128 x i8], [128 x i8]* %6, i64 0, i64 0
%15 = call i32 @read(i32 %13, i8* %14, i32 128)
%16 = getelementptr inbounds [128 x i8], [128 x i8]* %6, i64 0, i64 0
%17 = call i64 @strcmp(i8* %16, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%18 = icmp eq i64 %17, 0
br i1 %18, label %19, label %20
19: ; preds = %10
br label %54
20: ; preds = %10
store i32 0, i32* %4
br label %21
21: ; preds = %45, %20
%22 = load i32, i32* %4
%23 = getelementptr inbounds [128 x i8], [128 x i8]* %6, i64 0, i64 0
%24 = call i32 @strlen(i8* %23)
%25 = icmp slt i32 %22, %24
br i1 %25, label %26, label %48
26: ; preds = %21
%27 = load i32, i32* %4
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds [128 x i8], [128 x i8]* %6, i64 0, i64 %28
%30 = load i8, i8* %29
%31 = call i64 @islower(i8 signext %30)
%32 = icmp ne i64 %31, 0
br i1 %32, label %33, label %44
33: ; preds = %26
%34 = load i32, i32* %4
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds [128 x i8], [128 x i8]* %6, i64 0, i64 %35
%37 = load i8, i8* %36
%38 = sext i8 %37 to i32
%39 = sub nsw i32 %38, 32
%40 = trunc i32 %39 to i8
%41 = load i32, i32* %4
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds [128 x i8], [128 x i8]* %6, i64 0, i64 %42
store i8 %40, i8* %43
br label %44
44: ; preds = %33, %26
br label %45
45: ; preds = %44
%46 = load i32, i32* %4
%47 = add nsw i32 %46, 1
store i32 %47, i32* %4
br label %21
48: ; preds = %21
%49 = load i32, i32* %5
%50 = getelementptr inbounds [128 x i8], [128 x i8]* %6, i64 0, i64 0
%51 = getelementptr inbounds [128 x i8], [128 x i8]* %6, i64 0, i64 0
%52 = call i32 @strlen(i8* %51)
%53 = call i32 @write(i32 %49, i8* %50, i32 %52)
br label %10
54: ; preds = %19
%55 = load i8*, i8** %2
ret i8* %55
}

LLVM IR (-O2):
@.str = [5 x i8] c"exit\00"
define noalias i8* @runner(i8* nocapture %0) {
%2 = alloca [128 x i8]
%3 = bitcast i8* %0 to i32*
%4 = load i32, i32* %3
%5 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 0
%6 = call i32 @memset(i8* %5, i8 signext 0, i32 128)
%7 = call i32 @read(i32 %4, i8* %5, i32 128)
%8 = call i64 @strcmp(i8* %5, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%9 = icmp eq i64 %8, 0
br i1 %9, label %34, label %10
10: ; preds = %1, %27
%11 = call i32 @strlen(i8* %5)
%12 = icmp sgt i32 %11, 0
br i1 %12, label %13, label %27
13: ; preds = %10, %22
%14 = phi i64 [ %23, %22 ], [ 0, %10 ]
%15 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 %14
%16 = load i8, i8* %15
%17 = call i64 @islower(i8 signext %16)
%18 = icmp eq i64 %17, 0
br i1 %18, label %22, label %19
19: ; preds = %13
%20 = load i8, i8* %15
%21 = add i8 %20, -32
store i8 %21, i8* %15
br label %22
22: ; preds = %13, %19
%23 = add nuw nsw i64 %14, 1
%24 = call i32 @strlen(i8* %5)
%25 = sext i32 %24 to i64
%26 = icmp slt i64 %23, %25
br i1 %26, label %13, label %27
27: ; preds = %22, %10
%28 = call i32 @strlen(i8* %5)
%29 = call i32 @write(i32 %4, i8* %5, i32 %28)
%30 = call i32 @memset(i8* %5, i8 signext 0, i32 128)
%31 = call i32 @read(i32 %4, i8* %5, i32 128)
%32 = call i64 @strcmp(i8* %5, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%33 = icmp eq i64 %32, 0
br i1 %33, label %34, label %10
34: ; preds = %27, %1
ret i8* undef
}