#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*/ free(char *);
int /*<<< orphan*/ printf(char *);
char *string_f90_to_c(char *);
int /*<<< orphan*/ strncpy(char *, char *, int);
int system(char *);
int system_c4_(char *command, long len_command) {
  char commandbuff[257];
  char *cmd;
  int val;
  strncpy(commandbuff, command, 257 - 1);
  if (len_command >= 257) {
    return -1;
  }
  commandbuff[257 - 1] = '\0';
  cmd = string_f90_to_c(commandbuff);
  if (cmd == (char *)0) {
    printf("string_f90_to_c returned with an error\n");
    free(cmd);
    return -1;
  }
  val = system(cmd);
  free(cmd);
  return val;
}


x86 assembly (clang, -O0):
<system_c4_>:
push   %rbp
mov    %rsp,%rbp
sub    $0x130,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
lea    -0x120(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    $0x100,%edx
call   1040 <strncpy@plt>
cmpq   $0x101,-0x18(%rbp)
jl     1192 <system_c4_+0x42>
movl   $0xffffffff,-0x4(%rbp)
jmp    1202 <system_c4_+0xb2>
movb   $0x0,-0x20(%rbp)
lea    -0x120(%rbp),%rdi
call   1070 <string_f90_to_c@plt>
mov    %rax,-0x128(%rbp)
cmpq   $0x0,-0x128(%rbp)
jne    11db <system_c4_+0x8b>
lea    0xe42(%rip),%rdi
call   1060 <printf@plt>
mov    -0x128(%rbp),%rdi
call   1030 <free@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1202 <system_c4_+0xb2>
mov    -0x128(%rbp),%rdi
call   1050 <system@plt>
mov    %eax,-0x12c(%rbp)
mov    -0x128(%rbp),%rdi
call   1030 <free@plt>
mov    -0x12c(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x130,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<system_c4_>:
push   %rbp
push   %rbx
sub    $0x108,%rsp
mov    %rsi,%rbx
mov    %rdi,%rsi
mov    %rsp,%rdi
mov    $0x100,%edx
call   1040 <strncpy@plt>
mov    $0xffffffff,%ebp
cmp    $0x100,%rbx
jg     11b4 <system_c4_+0x64>
movb   $0x0,0x100(%rsp)
mov    %rsp,%rdi
call   1070 <string_f90_to_c@plt>
test   %rax,%rax
je     11a1 <system_c4_+0x51>
mov    %rax,%rbx
mov    %rax,%rdi
call   1060 <system@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
jmp    11af <system_c4_+0x5f>
lea    0xe58(%rip),%rdi
call   1050 <puts@plt>
xor    %edi,%edi
call   1030 <free@plt>
mov    %ebp,%eax
add    $0x108,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [40 x i8] c"string_f90_to_c returned with an error\0A\00"
define i32 @system_c4_(i8* %0, i64 %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i64
%6 = alloca [257 x i8]
%7 = alloca i8*
%8 = alloca i32
store i8* %0, i8** %4
store i64 %1, i64* %5
%9 = getelementptr inbounds [257 x i8], [257 x i8]* %6, i64 0, i64 0
%10 = load i8*, i8** %4
%11 = call i32 @strncpy(i8* %9, i8* %10, i32 256)
%12 = load i64, i64* %5
%13 = icmp sge i64 %12, 257
br i1 %13, label %14, label %15
14: ; preds = %2
store i32 -1, i32* %3
br label %31
15: ; preds = %2
%16 = getelementptr inbounds [257 x i8], [257 x i8]* %6, i64 0, i64 256
store i8 0, i8* %16
%17 = getelementptr inbounds [257 x i8], [257 x i8]* %6, i64 0, i64 0
%18 = call i8* @string_f90_to_c(i8* %17)
store i8* %18, i8** %7
%19 = load i8*, i8** %7
%20 = icmp eq i8* %19, null
br i1 %20, label %21, label %25
21: ; preds = %15
%22 = call i32 @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0))
%23 = load i8*, i8** %7
%24 = call i32 @free(i8* %23)
store i32 -1, i32* %3
br label %31
25: ; preds = %15
%26 = load i8*, i8** %7
%27 = call i32 @system(i8* %26)
store i32 %27, i32* %8
%28 = load i8*, i8** %7
%29 = call i32 @free(i8* %28)
%30 = load i32, i32* %8
store i32 %30, i32* %3
br label %31
31: ; preds = %25, %21, %14
%32 = load i32, i32* %3
ret i32 %32
}

LLVM IR (-O2):
@str = [39 x i8] c"string_f90_to_c returned with an error\00"
define i32 @system_c4_(i8* %0, i64 %1) {
%3 = alloca [257 x i8]
%4 = getelementptr inbounds [257 x i8], [257 x i8]* %3, i64 0, i64 0
%5 = call i32 @strncpy(i8* %4, i8* %0, i32 256)
%6 = icmp sgt i64 %1, 256
br i1 %6, label %17, label %7
7: ; preds = %2
%8 = getelementptr inbounds [257 x i8], [257 x i8]* %3, i64 0, i64 256
store i8 0, i8* %8
%9 = call i8* @string_f90_to_c(i8* %4)
%10 = icmp eq i8* %9, null
br i1 %10, label %11, label %14
11: ; preds = %7
%12 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @str, i64 0, i64 0))
%13 = call i32 @free(i8* null)
br label %17
14: ; preds = %7
%15 = call i32 @system(i8* %9)
%16 = call i32 @free(i8* %9)
br label %17
17: ; preds = %2, %14, %11
%18 = phi i32 [ -1, %11 ], [ %15, %14 ], [ -1, %2 ]
ret i32 %18
}