#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 */
struct test_cmd {
  int dummy;
};
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ dump_command(struct test_cmd *);
scalar_t__ execute_commands(struct test_cmd *);
int /*<<< orphan*/ feof(int /*<<< orphan*/ *);
scalar_t__ fgets(char *, int, int /*<<< orphan*/ *);
struct test_cmd *parse_line(char *);
int /*<<< orphan*/ printf(char *);
int test_execute(FILE *fptr) {
  char line_buffer[256];
  struct test_cmd *cmdptr;
  while (fptr && !feof(fptr)) {
    if (fgets(line_buffer, 256, fptr))
      cmdptr = parse_line(line_buffer);
    dump_command(cmdptr);
    if (execute_commands(cmdptr)) {
      printf("Failed to execute the commands\n");
      return -1;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<test_execute>:
push   %rbp
mov    %rsp,%rbp
sub    $0x120,%rsp
mov    %rdi,-0x10(%rbp)
xor    %eax,%eax
cmpq   $0x0,-0x10(%rbp)
mov    %al,-0x119(%rbp)
je     1199 <test_execute+0x39>
mov    -0x10(%rbp),%rdi
call   1050 <feof@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
mov    %al,-0x119(%rbp)
mov    -0x119(%rbp),%al
test   $0x1,%al
jne    11ac <test_execute+0x4c>
jmp    121d <test_execute+0xbd>
lea    -0x110(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    $0x100,%esi
call   1040 <fgets@plt>
cmp    $0x0,%rax
je     11de <test_execute+0x7e>
lea    -0x110(%rbp),%rdi
call   1060 <parse_line@plt>
mov    %rax,-0x118(%rbp)
mov    -0x118(%rbp),%rdi
call   1080 <dump_command@plt>
mov    -0x118(%rbp),%rdi
call   1070 <execute_commands@plt>
cmp    $0x0,%rax
je     1218 <test_execute+0xb8>
lea    0xdf9(%rip),%rdi
call   1030 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1224 <test_execute+0xc4>
jmp    116f <test_execute+0xf>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x120,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_execute>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x108,%rsp
xor    %r14d,%r14d
test   %rdi,%rdi
je     11d5 <test_execute+0x75>
mov    %rdi,%rbx
mov    %rsp,%r15
jmp    1195 <test_execute+0x35>
nopl   (%rax)
mov    %rbp,%rdi
call   1080 <dump_command@plt>
mov    %rbp,%rdi
call   1070 <execute_commands@plt>
test   %rax,%rax
jne    11c3 <test_execute+0x63>
mov    %rbx,%rdi
call   1050 <feof@plt>
test   %eax,%eax
jne    11d5 <test_execute+0x75>
mov    %r15,%rdi
mov    $0x100,%esi
mov    %rbx,%rdx
call   1040 <fgets@plt>
test   %rax,%rax
je     1180 <test_execute+0x20>
mov    %r15,%rdi
call   1060 <parse_line@plt>
mov    %rax,%rbp
jmp    1180 <test_execute+0x20>
lea    0xe36(%rip),%rdi
call   1030 <puts@plt>
mov    $0xffffffff,%r14d
mov    %r14d,%eax
add    $0x108,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.test_cmd = type { i32 }
@.str = [32 x i8] c"Failed to execute the commands\0A\00"
define i32 @test_execute(i32* %0) {
%2 = alloca i32
%3 = alloca i32*
%4 = alloca [256 x i8]
%5 = alloca %struct.test_cmd*
store i32* %0, i32** %3
br label %6
6: ; preds = %32, %1
%7 = load i32*, i32** %3
%8 = icmp ne i32* %7, null
br i1 %8, label %9, label %14
9: ; preds = %6
%10 = load i32*, i32** %3
%11 = call i32 @feof(i32* %10)
%12 = icmp ne i32 %11, 0
%13 = xor i1 %12, true
br label %14
14: ; preds = %9, %6
%15 = phi i1 [ false, %6 ], [ %13, %9 ]
br i1 %15, label %16, label %33
16: ; preds = %14
%17 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 0
%18 = load i32*, i32** %3
%19 = call i64 @fgets(i8* %17, i32 256, i32* %18)
%20 = icmp ne i64 %19, 0
br i1 %20, label %21, label %24
21: ; preds = %16
%22 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 0
%23 = call %struct.test_cmd* @parse_line(i8* %22)
store %struct.test_cmd* %23, %struct.test_cmd** %5
br label %24
24: ; preds = %21, %16
%25 = load %struct.test_cmd*, %struct.test_cmd** %5
%26 = call i32 @dump_command(%struct.test_cmd* %25)
%27 = load %struct.test_cmd*, %struct.test_cmd** %5
%28 = call i64 @execute_commands(%struct.test_cmd* %27)
%29 = icmp ne i64 %28, 0
br i1 %29, label %30, label %32
30: ; preds = %24
%31 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %2
br label %34
32: ; preds = %24
br label %6
33: ; preds = %14
store i32 0, i32* %2
br label %34
34: ; preds = %33, %30
%35 = load i32, i32* %2
ret i32 %35
}

LLVM IR (-O2):
%struct.test_cmd = type { i32 }
@str = [31 x i8] c"Failed to execute the commands\00"
define i32 @test_execute(i32* %0) {
%2 = alloca [256 x i8]
%3 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%4 = icmp eq i32* %0, null
br i1 %4, label %21, label %5
5: ; preds = %1, %14
%6 = phi %struct.test_cmd* [ %15, %14 ], [ undef, %1 ]
%7 = call i32 @feof(i32* %0)
%8 = icmp eq i32 %7, 0
br i1 %8, label %9, label %21
9: ; preds = %5
%10 = call i64 @fgets(i8* %3, i32 256, i32* %0)
%11 = icmp eq i64 %10, 0
br i1 %11, label %14, label %12
12: ; preds = %9
%13 = call %struct.test_cmd* @parse_line(i8* %3)
br label %14
14: ; preds = %12, %9
%15 = phi %struct.test_cmd* [ %13, %12 ], [ %6, %9 ]
%16 = call i32 @dump_command(%struct.test_cmd* %15)
%17 = call i64 @execute_commands(%struct.test_cmd* %15)
%18 = icmp eq i64 %17, 0
br i1 %18, label %5, label %19
19: ; preds = %14
%20 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @str, i64 0, i64 0))
br label %21
21: ; preds = %5, %1, %19
%22 = phi i32 [ -1, %19 ], [ 0, %1 ], [ 0, %5 ]
ret i32 %22
}