#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*/ strcat(char *, char *);
int /*<<< orphan*/ strncat(char *, char *, int);
int system(char *);
int grep(char *file, char *motif) {
  char cmd[150] = "grep -q ";
  strncat(cmd, motif, 50);
  strcat(cmd, " ");
  strncat(cmd, file, 50);
  return (system(cmd));
}


x86 assembly (clang, -O0):
<grep>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0xb0(%rbp),%rdi
lea    0xe9f(%rip),%rsi
mov    $0x96,%edx
call   1050 <memcpy@plt>
lea    -0xb0(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    $0x32,%edx
call   1040 <strncat@plt>
lea    -0xb0(%rbp),%rdi
lea    0xf08(%rip),%rsi
call   1060 <strcat@plt>
lea    -0xb0(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    $0x32,%edx
call   1040 <strncat@plt>
lea    -0xb0(%rbp),%rdi
call   1030 <system@plt>
add    $0xb0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<grep>:
push   %r15
push   %r14
push   %rbx
sub    $0xa0,%rsp
mov    %rsi,%r15
mov    %rdi,%r14
lea    0xea7(%rip),%rsi
mov    %rsp,%rbx
mov    $0x96,%edx
mov    %rbx,%rdi
call   1050 <memcpy@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
mov    $0x32,%edx
call   1040 <strncat@plt>
lea    0xf16(%rip),%rsi
mov    %rbx,%rdi
call   1060 <strcat@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x32,%edx
call   1040 <strncat@plt>
mov    %rbx,%rdi
call   1030 <system@plt>
add    $0xa0,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@__const.grep.cmd = [150 x i8] c"grep -q \00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00"
@.str = [2 x i8] c" \00"
define i32 @grep(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca [150 x i8]
store i8* %0, i8** %3
store i8* %1, i8** %4
%6 = bitcast [150 x i8]* %5 to i8*
%7 = getelementptr inbounds [150 x i8], [150 x i8]* %5, i64 0, i64 0
%8 = load i8*, i8** %4
%9 = call i32 @strncat(i8* %7, i8* %8, i32 50)
%10 = getelementptr inbounds [150 x i8], [150 x i8]* %5, i64 0, i64 0
%11 = call i32 @strcat(i8* %10, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%12 = getelementptr inbounds [150 x i8], [150 x i8]* %5, i64 0, i64 0
%13 = load i8*, i8** %3
%14 = call i32 @strncat(i8* %12, i8* %13, i32 50)
%15 = getelementptr inbounds [150 x i8], [150 x i8]* %5, i64 0, i64 0
%16 = call i32 @system(i8* %15)
ret i32 %16
}

LLVM IR (-O2):
@__const.grep.cmd = [150 x i8] c"grep -q \00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00"
@.str = [2 x i8] c" \00"
define i32 @grep(i8* %0, i8* %1) {
%3 = alloca [150 x i8]
%4 = getelementptr inbounds [150 x i8], [150 x i8]* %3, i64 0, i64 0
%5 = call i32 @strncat(i8* %4, i8* %1, i32 50)
%6 = call i32 @strcat(i8* %4, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%7 = call i32 @strncat(i8* %4, i8* %0, i32 50)
%8 = call i32 @system(i8* %4)
ret i32 %8
}