#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*/ fprintf(int /*<<< orphan*/, char *);
int sem_unlink(char *);
int shm_unlink(char *);
int /*<<< orphan*/ stderr;
void free_resources(void) {
  if (sem_unlink("/1328036sem_1") == -1) {
    (void)fprintf(stderr, "Problem while executing sem_unlink(3).\n");
  }
  if (sem_unlink("/1328036sem_2") == -1) {
    (void)fprintf(stderr, "Problem while executing sem_unlink(3).\n");
  }
  if (sem_unlink("/1328036sem_3") == -1) {
    (void)fprintf(stderr, "Problem while executing sem_unlink(3).\n");
  }
  if (shm_unlink("/1328036myshm") == -1) {
    (void)fprintf(stderr, "Problem while executing shm_unlink(3).\n");
  }
}


x86 assembly (clang, -O0):
<free_resources>:
push   %rbp
mov    %rsp,%rbp
lea    0xec5(%rip),%rdi
call   1050 <sem_unlink@plt>
cmp    $0xffffffff,%eax
jne    115e <free_resources+0x2e>
mov    0x2e90(%rip),%rax
mov    (%rax),%edi
lea    0xeb5(%rip),%rsi
call   1030 <fprintf@plt>
lea    0xed1(%rip),%rdi
call   1050 <sem_unlink@plt>
cmp    $0xffffffff,%eax
jne    1188 <free_resources+0x58>
mov    0x2e66(%rip),%rax
mov    (%rax),%edi
lea    0xe8b(%rip),%rsi
call   1030 <fprintf@plt>
lea    0xeb5(%rip),%rdi
call   1050 <sem_unlink@plt>
cmp    $0xffffffff,%eax
jne    11b2 <free_resources+0x82>
mov    0x2e3c(%rip),%rax
mov    (%rax),%edi
lea    0xe61(%rip),%rsi
call   1030 <fprintf@plt>
lea    0xe99(%rip),%rdi
call   1040 <shm_unlink@plt>
cmp    $0xffffffff,%eax
jne    11dc <free_resources+0xac>
mov    0x2e12(%rip),%rax
mov    (%rax),%edi
lea    0xe89(%rip),%rsi
call   1030 <fprintf@plt>
pop    %rbp
ret

x86 assembly (clang, -O2):
<free_resources>:
push   %rax
lea    0xec8(%rip),%rdi
call   1050 <sem_unlink@plt>
cmp    $0xffffffff,%eax
jne    1157 <free_resources+0x27>
mov    0x2e97(%rip),%rax
mov    (%rax),%edi
lea    0xebc(%rip),%rsi
call   1030 <fprintf@plt>
lea    0xed8(%rip),%rdi
call   1050 <sem_unlink@plt>
cmp    $0xffffffff,%eax
jne    117d <free_resources+0x4d>
mov    0x2e71(%rip),%rax
mov    (%rax),%edi
lea    0xe96(%rip),%rsi
call   1030 <fprintf@plt>
lea    0xec0(%rip),%rdi
call   1050 <sem_unlink@plt>
cmp    $0xffffffff,%eax
jne    11a3 <free_resources+0x73>
mov    0x2e4b(%rip),%rax
mov    (%rax),%edi
lea    0xe70(%rip),%rsi
call   1030 <fprintf@plt>
lea    0xea8(%rip),%rdi
call   1040 <shm_unlink@plt>
cmp    $0xffffffff,%eax
je     11b6 <free_resources+0x86>
pop    %rax
ret
mov    0x2e23(%rip),%rax
mov    (%rax),%edi
lea    0xe9a(%rip),%rsi
pop    %rax
jmp    1030 <fprintf@plt>

LLVM IR (-O0):
@.str = [14 x i8] c"/1328036sem_1\00"
@stderr = global i32 0
@.str.1 = [40 x i8] c"Problem while executing sem_unlink(3).\0A\00"
@.str.2 = [14 x i8] c"/1328036sem_2\00"
@.str.3 = [14 x i8] c"/1328036sem_3\00"
@.str.4 = [14 x i8] c"/1328036myshm\00"
@.str.5 = [40 x i8] c"Problem while executing shm_unlink(3).\0A\00"
define void @free_resources() {
%1 = call i32 @sem_unlink(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
%2 = icmp eq i32 %1, -1
br i1 %2, label %3, label %6
3: ; preds = %0
%4 = load i32, i32* @stderr
%5 = call i32 @fprintf(i32 %4, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.1, i64 0, i64 0))
br label %6
6: ; preds = %3, %0
%7 = call i32 @sem_unlink(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0))
%8 = icmp eq i32 %7, -1
br i1 %8, label %9, label %12
9: ; preds = %6
%10 = load i32, i32* @stderr
%11 = call i32 @fprintf(i32 %10, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.1, i64 0, i64 0))
br label %12
12: ; preds = %9, %6
%13 = call i32 @sem_unlink(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0))
%14 = icmp eq i32 %13, -1
br i1 %14, label %15, label %18
15: ; preds = %12
%16 = load i32, i32* @stderr
%17 = call i32 @fprintf(i32 %16, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.1, i64 0, i64 0))
br label %18
18: ; preds = %15, %12
%19 = call i32 @shm_unlink(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0))
%20 = icmp eq i32 %19, -1
br i1 %20, label %21, label %24
21: ; preds = %18
%22 = load i32, i32* @stderr
%23 = call i32 @fprintf(i32 %22, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.5, i64 0, i64 0))
br label %24
24: ; preds = %21, %18
ret void
}

LLVM IR (-O2):
@.str = [14 x i8] c"/1328036sem_1\00"
@stderr = global i32 0
@.str.1 = [40 x i8] c"Problem while executing sem_unlink(3).\0A\00"
@.str.2 = [14 x i8] c"/1328036sem_2\00"
@.str.3 = [14 x i8] c"/1328036sem_3\00"
@.str.4 = [14 x i8] c"/1328036myshm\00"
@.str.5 = [40 x i8] c"Problem while executing shm_unlink(3).\0A\00"
define void @free_resources() {
%1 = tail call i32 @sem_unlink(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
%2 = icmp eq i32 %1, -1
br i1 %2, label %3, label %6
3: ; preds = %0
%4 = load i32, i32* @stderr
%5 = tail call i32 @fprintf(i32 %4, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.1, i64 0, i64 0))
br label %6
6: ; preds = %3, %0
%7 = tail call i32 @sem_unlink(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0))
%8 = icmp eq i32 %7, -1
br i1 %8, label %9, label %12
9: ; preds = %6
%10 = load i32, i32* @stderr
%11 = tail call i32 @fprintf(i32 %10, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.1, i64 0, i64 0))
br label %12
12: ; preds = %9, %6
%13 = tail call i32 @sem_unlink(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0))
%14 = icmp eq i32 %13, -1
br i1 %14, label %15, label %18
15: ; preds = %12
%16 = load i32, i32* @stderr
%17 = tail call i32 @fprintf(i32 %16, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.1, i64 0, i64 0))
br label %18
18: ; preds = %15, %12
%19 = tail call i32 @shm_unlink(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0))
%20 = icmp eq i32 %19, -1
br i1 %20, label %21, label %24
21: ; preds = %18
%22 = load i32, i32* @stderr
%23 = tail call i32 @fprintf(i32 %22, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.5, i64 0, i64 0))
br label %24
24: ; preds = %21, %18
ret void
}