#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 /*<<< orphan*/ O_WRONLY;
int /*<<< orphan*/ close(int);
int open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ write(int, int *, int);
int main5(int argc, char **argv) {
  int fd;
  int letra = 'a';
  fd = open(argv[1], O_WRONLY);
  while (letra <= 'z') {
    write(fd, &letra, 1);
    letra++;
  }
  close(fd);
}


x86 assembly (clang, -O0):
<main5>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x61,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    0x2e83(%rip),%rax
mov    (%rax),%esi
call   1050 <open@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x7a,-0x18(%rbp)
jg     1188 <main5+0x58>
mov    -0x14(%rbp),%edi
lea    -0x18(%rbp),%rsi
mov    $0x1,%edx
call   1030 <write@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    115f <main5+0x2f>
mov    -0x14(%rbp),%edi
call   1040 <close@plt>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main5>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
movl   $0x61,0xc(%rsp)
mov    0x8(%rsi),%rdi
mov    0x2e8d(%rip),%rax
mov    (%rax),%esi
call   1050 <open@plt>
mov    %eax,%ebx
mov    $0x62,%ebp
lea    0xc(%rsp),%r14
xchg   %ax,%ax
mov    %ebx,%edi
mov    %r14,%rsi
mov    $0x1,%edx
call   1030 <write@plt>
mov    %ebp,0xc(%rsp)
add    $0x1,%ebp
cmp    $0x7c,%ebp
jne    1160 <main5+0x30>
mov    %ebx,%edi
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
jmp    1040 <close@plt>

LLVM IR (-O0):
@O_WRONLY = global i32 0
define i32 @main5(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 97, i32* %7
%8 = load i8**, i8*** %5
%9 = getelementptr inbounds i8*, i8** %8, i64 1
%10 = load i8*, i8** %9
%11 = load i32, i32* @O_WRONLY
%12 = call i32 @open(i8* %10, i32 %11)
store i32 %12, i32* %6
br label %13
13: ; preds = %16, %2
%14 = load i32, i32* %7
%15 = icmp sle i32 %14, 122
br i1 %15, label %16, label %21
16: ; preds = %13
%17 = load i32, i32* %6
%18 = call i32 @write(i32 %17, i32* %7, i32 1)
%19 = load i32, i32* %7
%20 = add nsw i32 %19, 1
store i32 %20, i32* %7
br label %13
21: ; preds = %13
%22 = load i32, i32* %6
%23 = call i32 @close(i32 %22)
%24 = load i32, i32* %3
ret i32 %24
}

LLVM IR (-O2):
@O_WRONLY = global i32 0
define i32 @main5(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
store i32 97, i32* %3
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = load i8*, i8** %5
%7 = load i32, i32* @O_WRONLY
%8 = tail call i32 @open(i8* %6, i32 %7)
br label %9
9: ; preds = %2, %9
%10 = phi i32 [ 97, %2 ], [ %12, %9 ]
%11 = call i32 @write(i32 %8, i32* %3, i32 1)
%12 = add nuw nsw i32 %10, 1
store i32 %12, i32* %3
%13 = icmp eq i32 %12, 123
br i1 %13, label %14, label %9
14: ; preds = %9
%15 = tail call i32 @close(i32 %8)
ret i32 undef
}