#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*/ execl(char *, char *, char *, char *, char *, char *, char *,
                         char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ exit(int);
scalar_t__ fork();
int /*<<< orphan*/ rename(char *, char *);
int /*<<< orphan*/ wait(int /*<<< orphan*/ *);
void capture(void) {
  if (fork() == 0) {
    execl("/bin/vidcat", "vidcat", "-f", "jpeg", "-s", "640x480", "-o",
          "/home/httpd/video/new.jpg", NULL);
    exit(1);
  }
  wait(NULL);
  rename("/home/httpd/video/new.jpg", "/home/httpd/video/image.jpg");
}


x86 assembly (clang, -O0):
<capture>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    $0x0,%al
call   1070 <fork@plt>
cmp    $0x0,%rax
jne    11c5 <capture+0x75>
lea    0xe90(%rip),%rdi
lea    0xe8e(%rip),%rsi
lea    0xe8e(%rip),%rdx
lea    0xe8a(%rip),%rcx
lea    0xe88(%rip),%r8
lea    0xe84(%rip),%r9
lea    0xe85(%rip),%r10
lea    0xe81(%rip),%rax
xor    %r11d,%r11d
mov    %r10,(%rsp)
mov    %rax,0x8(%rsp)
movq   $0x0,0x10(%rsp)
call   1050 <execl@plt>
mov    $0x1,%edi
call   1040 <exit@plt>
xor    %eax,%eax
mov    %eax,%edi
call   1060 <wait@plt>
lea    0xe4d(%rip),%rdi
lea    0xe60(%rip),%rsi
call   1030 <rename@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<capture>:
push   %rax
xor    %eax,%eax
call   1070 <fork@plt>
test   %rax,%rax
je     1178 <capture+0x28>
xor    %edi,%edi
call   1060 <wait@plt>
lea    0xeb7(%rip),%rdi
lea    0xeca(%rip),%rsi
pop    %rax
jmp    1030 <rename@plt>
sub    $0x8,%rsp
lea    0xe9f(%rip),%rax
lea    0xe95(%rip),%r10
lea    0xe6f(%rip),%rdi
lea    0xe6d(%rip),%rsi
lea    0xe6d(%rip),%rdx
lea    0xe69(%rip),%rcx
lea    0xe67(%rip),%r8
lea    0xe63(%rip),%r9
push   $0x0
push   %rax
push   %r10
call   1050 <execl@plt>
add    $0x20,%rsp
mov    $0x1,%edi
call   1040 <exit@plt>

LLVM IR (-O0):
@.str = [12 x i8] c"/bin/vidcat\00"
@.str.1 = [7 x i8] c"vidcat\00"
@.str.2 = [3 x i8] c"-f\00"
@.str.3 = [5 x i8] c"jpeg\00"
@.str.4 = [3 x i8] c"-s\00"
@.str.5 = [8 x i8] c"640x480\00"
@.str.6 = [3 x i8] c"-o\00"
@.str.7 = [26 x i8] c"/home/httpd/video/new.jpg\00"
@.str.8 = [28 x i8] c"/home/httpd/video/image.jpg\00"
define void @capture() {
%1 = call i64 (...) @fork()
%2 = icmp eq i64 %1, 0
br i1 %2, label %3, label %6
3: ; preds = %0
%4 = call i32 @execl(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.7, i64 0, i64 0), i32* null)
%5 = call i32 @exit(i32 1)
unreachable
6: ; preds = %0
%7 = call i32 @wait(i32* null)
%8 = call i32 @rename(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.8, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [12 x i8] c"/bin/vidcat\00"
@.str.1 = [7 x i8] c"vidcat\00"
@.str.2 = [3 x i8] c"-f\00"
@.str.3 = [5 x i8] c"jpeg\00"
@.str.4 = [3 x i8] c"-s\00"
@.str.5 = [8 x i8] c"640x480\00"
@.str.6 = [3 x i8] c"-o\00"
@.str.7 = [26 x i8] c"/home/httpd/video/new.jpg\00"
@.str.8 = [28 x i8] c"/home/httpd/video/image.jpg\00"
define void @capture() {
%1 = tail call i64 (...) @fork()
%2 = icmp eq i64 %1, 0
br i1 %2, label %3, label %6
3: ; preds = %0
%4 = tail call i32 @execl(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.7, i64 0, i64 0), i32* null)
%5 = tail call i32 @exit(i32 1)
unreachable
6: ; preds = %0
%7 = tail call i32 @wait(i32* null)
%8 = tail call i32 @rename(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.8, i64 0, i64 0))
ret void
}