#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 atoi(char *);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ p(int);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ sleep(int);
int /*<<< orphan*/ v(int);
int main(int argc, char *argv[]) {
  int i;
  int semid;
  semid = atoi(argv[1]);
  for (i = 0; i < 5; i++) {
    ;
    p(semid);
    printf("%s\n", argv[2]);
    sleep(1);
    printf("%s\n", argv[2]);
    v(semid);
  }
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1060 <atoi@plt>
mov    %eax,-0x18(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x5,-0x14(%rbp)
jge    11e7 <main+0x87>
mov    -0x18(%rbp),%edi
call   1030 <p@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rsi
lea    0xe52(%rip),%rdi
call   1050 <printf@plt>
mov    $0x1,%edi
call   1080 <sleep@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rsi
lea    0xe34(%rip),%rdi
call   1050 <printf@plt>
mov    -0x18(%rbp),%edi
call   1040 <v@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    118d <main+0x2d>
xor    %edi,%edi
call   1070 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%rbx
mov    0x8(%rsi),%rdi
call   1060 <atoi@plt>
mov    %eax,%ebp
mov    %eax,%edi
call   1030 <p@plt>
mov    0x10(%rbx),%rsi
lea    0xe7c(%rip),%r14
mov    %r14,%rdi
call   1050 <printf@plt>
mov    $0x1,%edi
call   1080 <sleep@plt>
mov    0x10(%rbx),%rsi
mov    %r14,%rdi
call   1050 <printf@plt>
mov    %ebp,%edi
call   1040 <v@plt>
mov    %ebp,%edi
call   1030 <p@plt>
mov    0x10(%rbx),%rsi
mov    %r14,%rdi
call   1050 <printf@plt>
mov    $0x1,%edi
call   1080 <sleep@plt>
mov    0x10(%rbx),%rsi
mov    %r14,%rdi
call   1050 <printf@plt>
mov    %ebp,%edi
call   1040 <v@plt>
mov    %ebp,%edi
call   1030 <p@plt>
mov    0x10(%rbx),%rsi
mov    %r14,%rdi
call   1050 <printf@plt>
mov    $0x1,%edi
call   1080 <sleep@plt>
mov    0x10(%rbx),%rsi
mov    %r14,%rdi
call   1050 <printf@plt>
mov    %ebp,%edi
call   1040 <v@plt>
mov    %ebp,%edi
call   1030 <p@plt>
mov    0x10(%rbx),%rsi
mov    %r14,%rdi
call   1050 <printf@plt>
mov    $0x1,%edi
call   1080 <sleep@plt>
mov    0x10(%rbx),%rsi
mov    %r14,%rdi
call   1050 <printf@plt>
mov    %ebp,%edi
call   1040 <v@plt>
mov    %ebp,%edi
call   1030 <p@plt>
mov    0x10(%rbx),%rsi
mov    %r14,%rdi
call   1050 <printf@plt>
mov    $0x1,%edi
call   1080 <sleep@plt>
mov    0x10(%rbx),%rsi
mov    %r14,%rdi
call   1050 <printf@plt>
mov    %ebp,%edi
call   1040 <v@plt>
xor    %edi,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@.str = [4 x i8] c"%s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = load i8**, i8*** %5
%9 = getelementptr inbounds i8*, i8** %8, i64 1
%10 = load i8*, i8** %9
%11 = call i32 @atoi(i8* %10)
store i32 %11, i32* %7
store i32 0, i32* %6
br label %12
12: ; preds = %29, %2
%13 = load i32, i32* %6
%14 = icmp slt i32 %13, 5
br i1 %14, label %15, label %32
15: ; preds = %12
%16 = load i32, i32* %7
%17 = call i32 @p(i32 %16)
%18 = load i8**, i8*** %5
%19 = getelementptr inbounds i8*, i8** %18, i64 2
%20 = load i8*, i8** %19
%21 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %20)
%22 = call i32 @sleep(i32 1)
%23 = load i8**, i8*** %5
%24 = getelementptr inbounds i8*, i8** %23, i64 2
%25 = load i8*, i8** %24
%26 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %25)
%27 = load i32, i32* %7
%28 = call i32 @v(i32 %27)
br label %29
29: ; preds = %15
%30 = load i32, i32* %6
%31 = add nsw i32 %30, 1
store i32 %31, i32* %6
br label %12
32: ; preds = %12
%33 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
@.str = [4 x i8] c"%s\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = getelementptr inbounds i8*, i8** %1, i64 1
%4 = load i8*, i8** %3
%5 = tail call i32 @atoi(i8* %4)
%6 = getelementptr inbounds i8*, i8** %1, i64 2
%7 = tail call i32 @p(i32 %5)
%8 = load i8*, i8** %6
%9 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %8)
%10 = tail call i32 @sleep(i32 1)
%11 = load i8*, i8** %6
%12 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %11)
%13 = tail call i32 @v(i32 %5)
%14 = tail call i32 @p(i32 %5)
%15 = load i8*, i8** %6
%16 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %15)
%17 = tail call i32 @sleep(i32 1)
%18 = load i8*, i8** %6
%19 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %18)
%20 = tail call i32 @v(i32 %5)
%21 = tail call i32 @p(i32 %5)
%22 = load i8*, i8** %6
%23 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %22)
%24 = tail call i32 @sleep(i32 1)
%25 = load i8*, i8** %6
%26 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %25)
%27 = tail call i32 @v(i32 %5)
%28 = tail call i32 @p(i32 %5)
%29 = load i8*, i8** %6
%30 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %29)
%31 = tail call i32 @sleep(i32 1)
%32 = load i8*, i8** %6
%33 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %32)
%34 = tail call i32 @v(i32 %5)
%35 = tail call i32 @p(i32 %5)
%36 = load i8*, i8** %6
%37 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %36)
%38 = tail call i32 @sleep(i32 1)
%39 = load i8*, i8** %6
%40 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %39)
%41 = tail call i32 @v(i32 %5)
%42 = tail call i32 @exit(i32 0)
unreachable
}