#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 get_wordid(char *, int);
int /*<<< orphan*/ put_word(int, int);
int strlen(char *);
char tolower(char);
void process_word(int fileid, int pos, char *word) {
  int i, wordid;
  for (i = 0; i < strlen(word); i++)
    word[i] = tolower(word[i]);
  wordid = get_wordid(word, 1);
  put_word(wordid, pos);
}


x86 assembly (clang, -O0):
<process_word>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x1c(%rbp),%eax
cmp    %ecx,%eax
jge    11a1 <process_word+0x61>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1040 <tolower@plt>
mov    %al,%dl
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1159 <process_word+0x19>
mov    -0x10(%rbp),%rdi
mov    $0x1,%esi
call   1060 <get_wordid@plt>
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%edi
mov    -0x8(%rbp),%esi
call   1050 <put_word@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<process_word>:
push   %rbp
push   %r14
push   %rbx
mov    %rdx,%rbx
mov    %esi,%r14d
mov    %rdx,%rdi
call   1030 <strlen@plt>
test   %eax,%eax
jle    117f <process_word+0x3f>
xor    %ebp,%ebp
nopl   0x0(%rax,%rax,1)
movsbl (%rbx,%rbp,1),%edi
call   1040 <tolower@plt>
mov    %al,(%rbx,%rbp,1)
add    $0x1,%rbp
mov    %rbx,%rdi
call   1030 <strlen@plt>
cltq
cmp    %rax,%rbp
jl     1160 <process_word+0x20>
mov    %rbx,%rdi
mov    $0x1,%esi
call   1060 <get_wordid@plt>
mov    %eax,%edi
mov    %r14d,%esi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1050 <put_word@plt>

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

LLVM IR (-O2):
define void @process_word(i32 %0, i32 %1, i8* %2) {
%4 = tail call i32 @strlen(i8* %2)
%5 = icmp sgt i32 %4, 0
br i1 %5, label %6, label %15
6: ; preds = %3, %6
%7 = phi i64 [ %11, %6 ], [ 0, %3 ]
%8 = getelementptr inbounds i8, i8* %2, i64 %7
%9 = load i8, i8* %8
%10 = tail call signext i8 @tolower(i8 signext %9)
store i8 %10, i8* %8
%11 = add nuw nsw i64 %7, 1
%12 = tail call i32 @strlen(i8* %2)
%13 = sext i32 %12 to i64
%14 = icmp slt i64 %11, %13
br i1 %14, label %6, label %15
15: ; preds = %6, %3
%16 = tail call i32 @get_wordid(i8* %2, i32 1)
%17 = tail call i32 @put_word(i32 %16, i32 %1)
ret void
}