#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*/ av_register_all();
int /*<<< orphan*/ avcodec_register_all();
int /*<<< orphan*/ avformat_network_init();
int ffmpeg(char *);
int ffprobe(char *, char *);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ sprintf(char *, char *, int, char *, int, int, char *);
int main() {
  int ret, argc;
  char info[10240];
  int width = 120;
  int height = 90;
  char *inputfile = "/root/1.3gp";
  char *outputfile = "/root/1.jpg";
  int starttime = 10;
  char cmd[1024];
  sprintf(cmd, "ffmpeg -ss %d -i %s -y -vframes 1 -s %d*%d %s", starttime,
          inputfile, width, height, outputfile);
  avcodec_register_all();
  av_register_all();
  avformat_network_init();
  ret = ffprobe(inputfile, info);
  if (ret)
    return ret;
  printf("info is [%s]\n", info);
  ret = ffmpeg(cmd);
  if (ret)
    return ret;
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x2c40,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x78,-0x2814(%rbp)
movl   $0x5a,-0x2818(%rbp)
lea    0xe63(%rip),%rax
mov    %rax,-0x2820(%rbp)
lea    0xe61(%rip),%rax
mov    %rax,-0x2828(%rbp)
movl   $0xa,-0x282c(%rbp)
lea    -0x2c30(%rbp),%rdi
mov    -0x282c(%rbp),%edx
mov    -0x2820(%rbp),%rcx
mov    -0x2814(%rbp),%r8d
mov    -0x2818(%rbp),%r9d
mov    -0x2828(%rbp),%rax
lea    0xe2c(%rip),%rsi
mov    %rax,(%rsp)
call   1080 <sprintf@plt>
mov    $0x0,%al
call   1090 <avcodec_register_all@plt>
mov    $0x0,%al
call   1040 <av_register_all@plt>
mov    $0x0,%al
call   1050 <avformat_network_init@plt>
mov    -0x2820(%rbp),%rdi
lea    -0x2810(%rbp),%rsi
call   1030 <ffprobe@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
je     1235 <main+0xc5>
mov    -0x8(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1273 <main+0x103>
lea    -0x2810(%rbp),%rsi
lea    0xe03(%rip),%rdi
call   1060 <printf@plt>
lea    -0x2c30(%rbp),%rdi
call   1070 <ffmpeg@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
je     126c <main+0xfc>
mov    -0x8(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1273 <main+0x103>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x2c40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x2c10,%rsp
lea    0xe8d(%rip),%rax
mov    %rax,(%rsp)
lea    0xe8e(%rip),%rsi
lea    0xe6f(%rip),%rbx
lea    0x10(%rsp),%rdi
mov    $0xa,%edx
mov    %rbx,%rcx
mov    $0x78,%r8d
mov    $0x5a,%r9d
call   1080 <sprintf@plt>
xor    %eax,%eax
call   1090 <avcodec_register_all@plt>
xor    %eax,%eax
call   1040 <av_register_all@plt>
xor    %eax,%eax
call   1050 <avformat_network_init@plt>
lea    0x410(%rsp),%rsi
mov    %rbx,%rdi
call   1030 <ffprobe@plt>
test   %eax,%eax
jne    11f6 <main+0x86>
lea    0xe67(%rip),%rdi
lea    0x410(%rsp),%rsi
call   1060 <printf@plt>
lea    0x10(%rsp),%rdi
call   1070 <ffmpeg@plt>
add    $0x2c10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [12 x i8] c"/root/1.3gp\00"
@.str.1 = [12 x i8] c"/root/1.jpg\00"
@.str.2 = [46 x i8] c"ffmpeg -ss %d -i %s -y -vframes 1 -s %d*%d %s\00"
@.str.3 = [14 x i8] c"info is [%s]\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca [10240 x i8]
%5 = alloca i32
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i32
%10 = alloca [1024 x i8]
store i32 0, i32* %1
store i32 120, i32* %5
store i32 90, i32* %6
store i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8** %7
store i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i8** %8
store i32 10, i32* %9
%11 = getelementptr inbounds [1024 x i8], [1024 x i8]* %10, i64 0, i64 0
%12 = load i32, i32* %9
%13 = load i8*, i8** %7
%14 = load i32, i32* %5
%15 = load i32, i32* %6
%16 = load i8*, i8** %8
%17 = call i32 @sprintf(i8* %11, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.2, i64 0, i64 0), i32 %12, i8* %13, i32 %14, i32 %15, i8* %16)
%18 = call i32 (...) @avcodec_register_all()
%19 = call i32 (...) @av_register_all()
%20 = call i32 (...) @avformat_network_init()
%21 = load i8*, i8** %7
%22 = getelementptr inbounds [10240 x i8], [10240 x i8]* %4, i64 0, i64 0
%23 = call i32 @ffprobe(i8* %21, i8* %22)
store i32 %23, i32* %2
%24 = load i32, i32* %2
%25 = icmp ne i32 %24, 0
br i1 %25, label %26, label %28
26: ; preds = %0
%27 = load i32, i32* %2
store i32 %27, i32* %1
br label %38
28: ; preds = %0
%29 = getelementptr inbounds [10240 x i8], [10240 x i8]* %4, i64 0, i64 0
%30 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i8* %29)
%31 = getelementptr inbounds [1024 x i8], [1024 x i8]* %10, i64 0, i64 0
%32 = call i32 @ffmpeg(i8* %31)
store i32 %32, i32* %2
%33 = load i32, i32* %2
%34 = icmp ne i32 %33, 0
br i1 %34, label %35, label %37
35: ; preds = %28
%36 = load i32, i32* %2
store i32 %36, i32* %1
br label %38
37: ; preds = %28
store i32 0, i32* %1
br label %38
38: ; preds = %37, %35, %26
%39 = load i32, i32* %1
ret i32 %39
}

LLVM IR (-O2):
@.str = [12 x i8] c"/root/1.3gp\00"
@.str.1 = [12 x i8] c"/root/1.jpg\00"
@.str.2 = [46 x i8] c"ffmpeg -ss %d -i %s -y -vframes 1 -s %d*%d %s\00"
@.str.3 = [14 x i8] c"info is [%s]\0A\00"
define i32 @main() {
%1 = alloca [10240 x i8]
%2 = alloca [1024 x i8]
%3 = getelementptr inbounds [10240 x i8], [10240 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%5 = call i32 @sprintf(i8* %4, i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @.str.2, i64 0, i64 0), i32 10, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 120, i32 90, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
%6 = tail call i32 (...) @avcodec_register_all()
%7 = tail call i32 (...) @av_register_all()
%8 = tail call i32 (...) @avformat_network_init()
%9 = call i32 @ffprobe(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* %3)
%10 = icmp eq i32 %9, 0
br i1 %10, label %11, label %14
11: ; preds = %0
%12 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i8* %3)
%13 = call i32 @ffmpeg(i8* %4)
br label %14
14: ; preds = %11, %0
%15 = phi i32 [ %9, %0 ], [ %13, %11 ]
ret i32 %15
}