#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*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ delete_word(char *);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ print_transducer(char *, char);
int /*<<< orphan*/ printf(char *, char *);
int strlen(char *);
void delete_words(char *filename) {
  FILE *file;
  if ((file = fopen(filename, "r")) == NULL) {
    printf("cmt: %s: No such file or directory.\n", filename);
    exit(EXIT_FAILURE);
  }
  char line[128];
  while (fgets(line, sizeof line, file) != NULL) {
    line[strlen(line) - 1] = '\0';
    delete_word(line);
  }
  fclose(file);
  print_transducer(filename, 'd');
}


x86 assembly (clang, -O0):
<delete_words>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe66(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
jne    11cb <delete_words+0x4b>
mov    -0x8(%rbp),%rsi
lea    0xe4a(%rip),%rdi
call   1050 <printf@plt>
mov    0x2e1c(%rip),%rax
mov    (%rax),%edi
call   10a0 <exit@plt>
jmp    11d0 <delete_words+0x50>
lea    -0x90(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    $0x80,%esi
call   1070 <fgets@plt>
cmp    $0x0,%rax
je     1219 <delete_words+0x99>
lea    -0x90(%rbp),%rdi
call   1040 <strlen@plt>
sub    $0x1,%eax
cltq
movb   $0x0,-0x90(%rbp,%rax,1)
lea    -0x90(%rbp),%rdi
call   1080 <delete_word@plt>
jmp    11d0 <delete_words+0x50>
mov    -0x10(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x8(%rbp),%rdi
mov    $0x64,%esi
call   1060 <print_transducer@plt>
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<delete_words>:
push   %r15
push   %r14
push   %rbx
sub    $0x80,%rsp
mov    %rdi,%r14
lea    0xe6a(%rip),%rsi
call   1090 <fopen@plt>
test   %rax,%rax
je     1200 <delete_words+0x80>
mov    %rax,%r15
mov    %rsp,%rbx
cs nopw 0x0(%rax,%rax,1)
mov    %rbx,%rdi
mov    $0x80,%esi
mov    %r15,%rdx
call   1070 <fgets@plt>
test   %rax,%rax
je     11de <delete_words+0x5e>
mov    %rbx,%rdi
call   1040 <strlen@plt>
cltq
movb   $0x0,-0x1(%rax,%rbx,1)
mov    %rbx,%rdi
call   1080 <delete_word@plt>
jmp    11b0 <delete_words+0x30>
mov    %r15,%rdi
call   1030 <fclose@plt>
mov    %r14,%rdi
mov    $0x64,%esi
call   1060 <print_transducer@plt>
add    $0x80,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret
lea    0xdfb(%rip),%rdi
mov    %r14,%rsi
call   1050 <printf@plt>
mov    0x2dca(%rip),%rax
mov    (%rax),%edi
call   10a0 <exit@plt>

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@.str.1 = [37 x i8] c"cmt: %s: No such file or directory.\0A\00"
@EXIT_FAILURE = global i32 0
define void @delete_words(i8* %0) {
%2 = alloca i8*
%3 = alloca i32*
%4 = alloca [128 x i8]
store i8* %0, i8** %2
%5 = load i8*, i8** %2
%6 = call i32* @fopen(i8* %5, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %6, i32** %3
%7 = icmp eq i32* %6, null
br i1 %7, label %8, label %13
8: ; preds = %1
%9 = load i8*, i8** %2
%10 = call i32 @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0), i8* %9)
%11 = load i32, i32* @EXIT_FAILURE
%12 = call i32 @exit(i32 %11)
unreachable
13: ; preds = %1
br label %14
14: ; preds = %19, %13
%15 = getelementptr inbounds [128 x i8], [128 x i8]* %4, i64 0, i64 0
%16 = load i32*, i32** %3
%17 = call i32* @fgets(i8* %15, i32 128, i32* %16)
%18 = icmp ne i32* %17, null
br i1 %18, label %19, label %27
19: ; preds = %14
%20 = getelementptr inbounds [128 x i8], [128 x i8]* %4, i64 0, i64 0
%21 = call i32 @strlen(i8* %20)
%22 = sub nsw i32 %21, 1
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds [128 x i8], [128 x i8]* %4, i64 0, i64 %23
store i8 0, i8* %24
%25 = getelementptr inbounds [128 x i8], [128 x i8]* %4, i64 0, i64 0
%26 = call i32 @delete_word(i8* %25)
br label %14
27: ; preds = %14
%28 = load i32*, i32** %3
%29 = call i32 @fclose(i32* %28)
%30 = load i8*, i8** %2
%31 = call i32 @print_transducer(i8* %30, i8 signext 100)
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@.str.1 = [37 x i8] c"cmt: %s: No such file or directory.\0A\00"
@EXIT_FAILURE = global i32 0
define void @delete_words(i8* %0) {
%2 = alloca [128 x i8]
%3 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%4 = icmp eq i32* %3, null
br i1 %4, label %5, label %9
5: ; preds = %1
%6 = tail call i32 @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0), i8* %0)
%7 = load i32, i32* @EXIT_FAILURE
%8 = tail call i32 @exit(i32 %7)
unreachable
9: ; preds = %1
%10 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 0
%11 = call i32* @fgets(i8* %10, i32 128, i32* %3)
%12 = icmp eq i32* %11, null
br i1 %12, label %21, label %13
13: ; preds = %9, %13
%14 = call i32 @strlen(i8* %10)
%15 = add nsw i32 %14, -1
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 %16
store i8 0, i8* %17
%18 = call i32 @delete_word(i8* %10)
%19 = call i32* @fgets(i8* %10, i32 128, i32* %3)
%20 = icmp eq i32* %19, null
br i1 %20, label %21, label %13
21: ; preds = %13, %9
%22 = call i32 @fclose(i32* %3)
%23 = call i32 @print_transducer(i8* %0, i8 signext 100)
ret void
}