#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(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fputs(char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *);
int main() {
  FILE *fp;
  if ((fp = fopen("arqtext.txt", "w")) == NULL) {
    printf("\nO arquivo não pode ser aberto");
    exit(1);
  } else {
    printf("\nO arquivo foi aberto para gravação");
  }
  fputs("Será que vai chover hoje?\n", fp);
  fputs("Belo Horizonte é a capital de Minas Gerais!\n", fp);
  fputs("Que vontade de pegar um praia!\n", fp);
  fclose(fp);
  printf("\nFim do programa!");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe9a(%rip),%rdi
lea    0xe9f(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
jne    1196 <main+0x46>
lea    0xe87(%rip),%rdi
call   1040 <printf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
lea    0xe91(%rip),%rdi
call   1040 <printf@plt>
mov    -0x10(%rbp),%rsi
lea    0xea7(%rip),%rdi
call   1050 <fputs@plt>
mov    -0x10(%rbp),%rsi
lea    0xeb3(%rip),%rdi
call   1050 <fputs@plt>
mov    -0x10(%rbp),%rsi
lea    0xed1(%rip),%rdi
call   1050 <fputs@plt>
mov    -0x10(%rbp),%rdi
call   1030 <fclose@plt>
lea    0xedc(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
lea    0xea8(%rip),%rdi
lea    0xead(%rip),%rsi
call   1050 <fopen@plt>
test   %rax,%rax
je     11db <main+0x8b>
mov    %rax,%rbx
lea    0xebb(%rip),%rdi
call   1040 <printf@plt>
lea    0xed5(%rip),%rdi
mov    $0x1b,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1070 <fwrite@plt>
lea    0xed8(%rip),%rdi
mov    $0x2d,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1070 <fwrite@plt>
lea    0xeed(%rip),%rdi
mov    $0x1f,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1070 <fwrite@plt>
mov    %rbx,%rdi
call   1030 <fclose@plt>
lea    0xeec(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
pop    %rbx
ret
lea    0xe2c(%rip),%rdi
call   1040 <printf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@.str = [12 x i8] c"arqtext.txt\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [32 x i8] c"\0AO arquivo n\C3\A3o pode ser aberto\00"
@.str.3 = [38 x i8] c"\0AO arquivo foi aberto para grava\C3\A7\C3\A3o\00"
@.str.4 = [28 x i8] c"Ser\C3\A1 que vai chover hoje?\0A\00"
@.str.5 = [46 x i8] c"Belo Horizonte \C3\A9 a capital de Minas Gerais!\0A\00"
@.str.6 = [32 x i8] c"Que vontade de pegar um praia!\0A\00"
@.str.7 = [18 x i8] c"\0AFim do programa!\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
store i32 0, i32* %1
%3 = call i32* @fopen(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %3, i32** %2
%4 = icmp eq i32* %3, null
br i1 %4, label %5, label %8
5: ; preds = %0
%6 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0))
%7 = call i32 @exit(i32 1)
unreachable
8: ; preds = %0
%9 = call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.3, i64 0, i64 0))
br label %10
10: ; preds = %8
%11 = load i32*, i32** %2
%12 = call i32 @fputs(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.4, i64 0, i64 0), i32* %11)
%13 = load i32*, i32** %2
%14 = call i32 @fputs(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.5, i64 0, i64 0), i32* %13)
%15 = load i32*, i32** %2
%16 = call i32 @fputs(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.6, i64 0, i64 0), i32* %15)
%17 = load i32*, i32** %2
%18 = call i32 @fclose(i32* %17)
%19 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.7, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str = [12 x i8] c"arqtext.txt\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [32 x i8] c"\0AO arquivo n\C3\A3o pode ser aberto\00"
@.str.3 = [38 x i8] c"\0AO arquivo foi aberto para grava\C3\A7\C3\A3o\00"
@.str.4 = [28 x i8] c"Ser\C3\A1 que vai chover hoje?\0A\00"
@.str.5 = [46 x i8] c"Belo Horizonte \C3\A9 a capital de Minas Gerais!\0A\00"
@.str.6 = [32 x i8] c"Que vontade de pegar um praia!\0A\00"
@.str.7 = [18 x i8] c"\0AFim do programa!\00"
define i32 @main() {
%1 = tail call i32* @fopen(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%2 = icmp eq i32* %1, null
br i1 %2, label %3, label %6
3: ; preds = %0
%4 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0))
%5 = tail call i32 @exit(i32 1)
unreachable
6: ; preds = %0
%7 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @.str.3, i64 0, i64 0))
%8 = tail call i64 @fwrite(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.4, i64 0, i64 0), i64 27, i64 1, i32* %1)
%9 = tail call i64 @fwrite(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.5, i64 0, i64 0), i64 45, i64 1, i32* %1)
%10 = tail call i64 @fwrite(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.6, i64 0, i64 0), i64 31, i64 1, i32* %1)
%11 = tail call i32 @fclose(i32* %1)
%12 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.7, i64 0, i64 0))
ret i32 0
}