#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 scalar_t__ pid_t;

/* Variables and functions */
int O_CREAT;
int O_WRONLY;
scalar_t__ WEXITSTATUS(int);
scalar_t__ WIFEXITED(int);
int /*<<< orphan*/ _exit(int /*<<< orphan*/);
int /*<<< orphan*/ dup2(int, int);
int /*<<< orphan*/ errno;
int /*<<< orphan*/ execlp(char *, char *, char *, char *, char *, char *,
                          int /*<<< orphan*/ *);
scalar_t__ fork();
int open(char *, int, int);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ waitpid(scalar_t__, int *, int /*<<< orphan*/);
int executa(char *palavra, char *arquivo, char *pronto) {
  pid_t pid;
  int status;
  pid = fork();
  if (pid == 0) {
    int fd = open(pronto, O_CREAT | O_WRONLY, 0600);
    dup2(fd, 1);
    execlp("gpg", "gpg", "-d", "--passphrase", palavra, arquivo, NULL);
    perror("ao executar o gpg !");
    _exit(errno);
  }
  waitpid(pid, &status, 0);
  if (WIFEXITED(status)) {
    if (WEXITSTATUS(status) == 0)
      return 1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<executa>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    $0x0,%al
call   10b0 <fork@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    1233 <executa+0xa3>
mov    -0x20(%rbp),%rdi
mov    0x2e33(%rip),%rax
mov    (%rax),%esi
mov    0x2dfa(%rip),%rax
or     (%rax),%esi
mov    $0x180,%edx
call   1070 <open@plt>
mov    %eax,-0x30(%rbp)
mov    -0x30(%rbp),%edi
mov    $0x1,%esi
call   1040 <dup2@plt>
mov    -0x10(%rbp),%r8
mov    -0x18(%rbp),%r9
lea    0xe07(%rip),%rsi
lea    0xe04(%rip),%rdx
lea    0xe00(%rip),%rcx
xor    %eax,%eax
mov    %rsi,%rdi
movq   $0x0,(%rsp)
call   10a0 <execlp@plt>
lea    0xdf4(%rip),%rdi
call   1080 <perror@plt>
mov    0x2dac(%rip),%rax
mov    (%rax),%edi
call   1030 <_exit@plt>
mov    -0x28(%rbp),%rdi
lea    -0x2c(%rbp),%rsi
xor    %edx,%edx
call   1060 <waitpid@plt>
mov    -0x2c(%rbp),%edi
call   1090 <WIFEXITED@plt>
cmp    $0x0,%rax
je     1277 <executa+0xe7>
mov    -0x2c(%rbp),%edi
call   1050 <WEXITSTATUS@plt>
cmp    $0x0,%rax
jne    1272 <executa+0xe2>
movl   $0x1,-0x4(%rbp)
jmp    127e <executa+0xee>
jmp    1277 <executa+0xe7>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<executa>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rdx,%rbx
mov    %rsi,%r14
mov    %rdi,%r15
xor    %eax,%eax
call   10b0 <fork@plt>
test   %rax,%rax
je     11ec <executa+0x5c>
lea    0xc(%rsp),%rsi
xor    %ebx,%ebx
mov    %rax,%rdi
xor    %edx,%edx
call   1060 <waitpid@plt>
mov    0xc(%rsp),%edi
call   1090 <WIFEXITED@plt>
test   %rax,%rax
je     11e0 <executa+0x50>
mov    0xc(%rsp),%edi
call   1050 <WEXITSTATUS@plt>
test   %rax,%rax
jne    11e0 <executa+0x50>
mov    $0x1,%ebx
mov    %ebx,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret
mov    0x2e05(%rip),%rax
mov    0x2dce(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
mov    %rbx,%rdi
mov    $0x180,%edx
call   1070 <open@plt>
mov    %eax,%edi
mov    $0x1,%esi
call   1040 <dup2@plt>
movq   $0x0,(%rsp)
lea    0xdda(%rip),%rdi
lea    0xdd7(%rip),%rdx
lea    0xdd3(%rip),%rcx
mov    %rdi,%rsi
mov    %r15,%r8
mov    %r14,%r9
call   10a0 <execlp@plt>
lea    0xdcb(%rip),%rdi
call   1080 <perror@plt>
mov    0x2d83(%rip),%rax
mov    (%rax),%edi
call   1030 <_exit@plt>

LLVM IR (-O0):
@O_CREAT = global i32 0
@O_WRONLY = global i32 0
@.str = [4 x i8] c"gpg\00"
@.str.1 = [3 x i8] c"-d\00"
@.str.2 = [13 x i8] c"--passphrase\00"
@.str.3 = [20 x i8] c"ao executar o gpg !\00"
@errno = global i32 0
define i32 @executa(i8* %0, i8* %1, i8* %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i64
%9 = alloca i32
%10 = alloca i32
store i8* %0, i8** %5
store i8* %1, i8** %6
store i8* %2, i8** %7
%11 = call i64 (...) @fork()
store i64 %11, i64* %8
%12 = load i64, i64* %8
%13 = icmp eq i64 %12, 0
br i1 %13, label %14, label %28
14: ; preds = %3
%15 = load i8*, i8** %7
%16 = load i32, i32* @O_CREAT
%17 = load i32, i32* @O_WRONLY
%18 = or i32 %16, %17
%19 = call i32 @open(i8* %15, i32 %18, i32 384)
store i32 %19, i32* %10
%20 = load i32, i32* %10
%21 = call i32 @dup2(i32 %20, i32 1)
%22 = load i8*, i8** %5
%23 = load i8*, i8** %6
%24 = call i32 @execlp(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i8* %22, i8* %23, i32* null)
%25 = call i32 @perror(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0))
%26 = load i32, i32* @errno
%27 = call i32 @_exit(i32 %26)
unreachable
28: ; preds = %3
%29 = load i64, i64* %8
%30 = call i32 @waitpid(i64 %29, i32* %9, i32 0)
%31 = load i32, i32* %9
%32 = call i64 @WIFEXITED(i32 %31)
%33 = icmp ne i64 %32, 0
br i1 %33, label %34, label %40
34: ; preds = %28
%35 = load i32, i32* %9
%36 = call i64 @WEXITSTATUS(i32 %35)
%37 = icmp eq i64 %36, 0
br i1 %37, label %38, label %39
38: ; preds = %34
store i32 1, i32* %4
br label %41
39: ; preds = %34
br label %40
40: ; preds = %39, %28
store i32 0, i32* %4
br label %41
41: ; preds = %40, %38
%42 = load i32, i32* %4
ret i32 %42
}

LLVM IR (-O2):
@O_CREAT = global i32 0
@O_WRONLY = global i32 0
@.str = [4 x i8] c"gpg\00"
@.str.1 = [3 x i8] c"-d\00"
@.str.2 = [13 x i8] c"--passphrase\00"
@.str.3 = [20 x i8] c"ao executar o gpg !\00"
@errno = global i32 0
define i32 @executa(i8* %0, i8* %1, i8* nocapture %2) {
%4 = alloca i32
%5 = bitcast i32* %4 to i8*
%6 = tail call i64 (...) @fork()
%7 = icmp eq i64 %6, 0
br i1 %7, label %8, label %18
8: ; preds = %3
%9 = load i32, i32* @O_CREAT
%10 = load i32, i32* @O_WRONLY
%11 = or i32 %10, %9
%12 = tail call i32 @open(i8* %2, i32 %11, i32 384)
%13 = tail call i32 @dup2(i32 %12, i32 1)
%14 = tail call i32 @execlp(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i8* %0, i8* %1, i32* null)
%15 = tail call i32 @perror(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0))
%16 = load i32, i32* @errno
%17 = tail call i32 @_exit(i32 %16)
unreachable
18: ; preds = %3
%19 = call i32 @waitpid(i64 %6, i32* %4, i32 0)
%20 = load i32, i32* %4
%21 = call i64 @WIFEXITED(i32 %20)
%22 = icmp eq i64 %21, 0
br i1 %22, label %27, label %23
23: ; preds = %18
%24 = load i32, i32* %4
%25 = call i64 @WEXITSTATUS(i32 %24)
%26 = icmp eq i64 %25, 0
br i1 %26, label %28, label %27
27: ; preds = %23, %18
br label %28
28: ; preds = %23, %27
%29 = phi i32 [ 0, %27 ], [ 1, %23 ]
ret i32 %29
}