#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*/ printf(char *, ...);
int /*<<< orphan*/ putchar(char);
int system(char *);
void apt_fullupgrade(char *prog) {
  int sc;
  printf("%s: Performing APT full upgrade...\n", prog);
  if ((sc = system("sleep 1 && apt full-upgrade")) == 0)
    printf("Done\n");
  else
    printf("%s: %s", prog, "Command failed to execute due to error(s).");
  putchar('\n');
}


x86 assembly (clang, -O0):
<apt_fullupgrade>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rsi
lea    0xeb9(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xecf(%rip),%rdi
call   1040 <system@plt>
mov    %eax,-0xc(%rbp)
cmp    $0x0,%eax
jne    1179 <apt_fullupgrade+0x49>
lea    0xed3(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    1192 <apt_fullupgrade+0x62>
mov    -0x8(%rbp),%rsi
lea    0xec2(%rip),%rdi
lea    0xec2(%rip),%rdx
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<apt_fullupgrade>:
push   %rbx
mov    %rdi,%rbx
lea    0xeb5(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xec8(%rip),%rdi
call   1050 <system@plt>
test   %eax,%eax
je     117f <apt_fullupgrade+0x3f>
lea    0xed4(%rip),%rdi
lea    0xed4(%rip),%rdx
mov    %rbx,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
jmp    118b <apt_fullupgrade+0x4b>
lea    0xeec(%rip),%rdi
call   1040 <puts@plt>
mov    $0xa,%edi
pop    %rbx
jmp    1030 <putchar@plt>

LLVM IR (-O0):
@.str = [36 x i8] c"%s: Performing APT full upgrade...\0A\00"
@.str.1 = [28 x i8] c"sleep 1 && apt full-upgrade\00"
@.str.2 = [6 x i8] c"Done\0A\00"
@.str.3 = [7 x i8] c"%s: %s\00"
@.str.4 = [43 x i8] c"Command failed to execute due to error(s).\00"
define void @apt_fullupgrade(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
store i8* %0, i8** %2
%4 = load i8*, i8** %2
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0), i8* %4)
%6 = call i32 @system(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0))
store i32 %6, i32* %3
%7 = icmp eq i32 %6, 0
br i1 %7, label %8, label %10
8: ; preds = %1
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
br label %13
10: ; preds = %1
%11 = load i8*, i8** %2
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i8* %11, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.4, i64 0, i64 0))
br label %13
13: ; preds = %10, %8
%14 = call i32 @putchar(i8 signext 10)
ret void
}

LLVM IR (-O2):
@.str = [36 x i8] c"%s: Performing APT full upgrade...\0A\00"
@.str.1 = [28 x i8] c"sleep 1 && apt full-upgrade\00"
@.str.3 = [7 x i8] c"%s: %s\00"
@.str.4 = [43 x i8] c"Command failed to execute due to error(s).\00"
@str = [5 x i8] c"Done\00"
define void @apt_fullupgrade(i8* %0) {
%2 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0), i8* %0)
%3 = tail call i32 @system(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0))
%4 = icmp eq i32 %3, 0
br i1 %4, label %5, label %7
5: ; preds = %1
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @str, i64 0, i64 0))
br label %9
7: ; preds = %1
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i8* %0, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.4, i64 0, i64 0))
br label %9
9: ; preds = %7, %5
%10 = tail call i32 @putchar(i8 signext 10)
ret void
}