#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 */
struct timeval {
  int dummy;
};
typedef scalar_t__ mqd_t;
typedef int /*<<< orphan*/ heure;

/* Variables and functions */
int /*<<< orphan*/ EXIT_FAILURE;
int EXIT_SUCCESS;
int O_CREAT;
int O_WRONLY;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ gettimeofday(struct timeval *, int /*<<< orphan*/ *);
scalar_t__ mq_open(char *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ mq_send(scalar_t__, char *, int, int);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, struct timeval *, int);
int /*<<< orphan*/ sleep(int);
int /*<<< orphan*/ stderr;
int main(int argc, char *argv[]) {
  mqd_t mq;
  struct timeval heure;
  if (argc != 2) {
    fprintf(stderr, "usage: %s nom_file_messagen", argv[0]);
    exit(EXIT_FAILURE);
  }
  mq = mq_open(argv[1], O_WRONLY | O_CREAT, 0600, NULL);
  if (mq == (mqd_t)-1) {
    perror(argv[1]);
    exit(EXIT_FAILURE);
  }
  while (1) {
    gettimeofday(&heure, NULL);
    printf("envoie de %p %lu\n", &heure, sizeof(heure));
    mq_send(mq, (char *)&heure, sizeof(heure), 1);
    sleep(1);
  }
  return EXIT_SUCCESS;
}


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)
cmpl   $0x2,-0x8(%rbp)
je     11ca <main+0x4a>
mov    0x2e31(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe49(%rip),%rsi
call   1060 <fprintf@plt>
mov    0x2e0d(%rip),%rax
mov    (%rax),%edi
call   1090 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    0x2de7(%rip),%rax
mov    (%rax),%esi
mov    0x2e16(%rip),%rax
or     (%rax),%esi
mov    $0x180,%edx
xor    %eax,%eax
mov    %eax,%ecx
call   1070 <mq_open@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0xffffffffffffffff,-0x18(%rbp)
jne    121c <main+0x9c>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1080 <perror@plt>
mov    0x2dbb(%rip),%rax
mov    (%rax),%edi
call   1090 <exit@plt>
jmp    1221 <main+0xa1>
lea    -0x20(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1040 <gettimeofday@plt>
lea    0xde7(%rip),%rdi
lea    -0x20(%rbp),%rsi
mov    $0x4,%edx
call   1030 <printf@plt>
mov    -0x18(%rbp),%rdi
lea    -0x20(%rbp),%rsi
mov    $0x4,%edx
mov    $0x1,%ecx
call   1050 <mq_send@plt>
mov    $0x1,%edi
call   10a0 <sleep@plt>
jmp    1221 <main+0xa1>

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%r14
cmp    $0x2,%edi
jne    120b <main+0x8b>
mov    0x8(%r14),%rdi
mov    0x2e24(%rip),%rax
mov    0x2e55(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
mov    $0x180,%edx
xor    %ecx,%ecx
call   1070 <mq_open@plt>
cmp    $0xffffffffffffffff,%rax
je     1225 <main+0xa5>
mov    %rax,%r15
lea    0x8(%rsp),%rbx
lea    0xe54(%rip),%r14
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rdi
xor    %esi,%esi
call   1040 <gettimeofday@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
mov    $0x4,%edx
call   1030 <printf@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
mov    $0x4,%edx
mov    $0x1,%ecx
call   1050 <mq_send@plt>
mov    $0x1,%edi
call   10a0 <sleep@plt>
jmp    11d0 <main+0x50>
mov    0x2dc6(%rip),%rax
mov    (%rax),%edi
mov    (%r14),%rdx
lea    0xde2(%rip),%rsi
call   1060 <fprintf@plt>
jmp    122e <main+0xae>
mov    0x8(%r14),%rdi
call   1080 <perror@plt>
mov    0x2d9b(%rip),%rax
mov    (%rax),%edi
call   1090 <exit@plt>

LLVM IR (-O0):
%struct.timeval = type { i32 }
@stderr = global i32 0
@.str = [28 x i8] c"usage: %s nom_file_messagen\00"
@EXIT_FAILURE = global i32 0
@O_WRONLY = global i32 0
@O_CREAT = global i32 0
@.str.1 = [18 x i8] c"envoie de %p %lu\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i64
%7 = alloca %struct.timeval
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = load i32, i32* %4
%9 = icmp ne i32 %8, 2
br i1 %9, label %10, label %18
10: ; preds = %2
%11 = load i32, i32* @stderr
%12 = load i8**, i8*** %5
%13 = getelementptr inbounds i8*, i8** %12, i64 0
%14 = load i8*, i8** %13
%15 = call i32 @fprintf(i32 %11, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i8* %14)
%16 = load i32, i32* @EXIT_FAILURE
%17 = call i32 @exit(i32 %16)
unreachable
18: ; preds = %2
%19 = load i8**, i8*** %5
%20 = getelementptr inbounds i8*, i8** %19, i64 1
%21 = load i8*, i8** %20
%22 = load i32, i32* @O_WRONLY
%23 = load i32, i32* @O_CREAT
%24 = or i32 %22, %23
%25 = call i64 @mq_open(i8* %21, i32 %24, i32 384, i32* null)
store i64 %25, i64* %6
%26 = load i64, i64* %6
%27 = icmp eq i64 %26, -1
br i1 %27, label %28, label %35
28: ; preds = %18
%29 = load i8**, i8*** %5
%30 = getelementptr inbounds i8*, i8** %29, i64 1
%31 = load i8*, i8** %30
%32 = call i32 @perror(i8* %31)
%33 = load i32, i32* @EXIT_FAILURE
%34 = call i32 @exit(i32 %33)
unreachable
35: ; preds = %18
br label %36
36: ; preds = %35, %36
%37 = call i32 @gettimeofday(%struct.timeval* %7, i32* null)
%38 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), %struct.timeval* %7, i32 4)
%39 = load i64, i64* %6
%40 = bitcast %struct.timeval* %7 to i8*
%41 = call i32 @mq_send(i64 %39, i8* %40, i32 4, i32 1)
%42 = call i32 @sleep(i32 1)
br label %36
}

LLVM IR (-O2):
%struct.timeval = type { i32 }
@stderr = global i32 0
@.str = [28 x i8] c"usage: %s nom_file_messagen\00"
@EXIT_FAILURE = global i32 0
@O_WRONLY = global i32 0
@O_CREAT = global i32 0
@.str.1 = [18 x i8] c"envoie de %p %lu\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca %struct.timeval
%4 = bitcast %struct.timeval* %3 to i8*
%5 = icmp eq i32 %0, 2
br i1 %5, label %12, label %6
6: ; preds = %2
%7 = load i32, i32* @stderr
%8 = load i8*, i8** %1
%9 = tail call i32 @fprintf(i32 %7, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i8* %8)
%10 = load i32, i32* @EXIT_FAILURE
%11 = tail call i32 @exit(i32 %10)
unreachable
12: ; preds = %2
%13 = getelementptr inbounds i8*, i8** %1, i64 1
%14 = load i8*, i8** %13
%15 = load i32, i32* @O_WRONLY
%16 = load i32, i32* @O_CREAT
%17 = or i32 %16, %15
%18 = tail call i64 @mq_open(i8* %14, i32 %17, i32 384, i32* null)
%19 = icmp eq i64 %18, -1
br i1 %19, label %20, label %25
20: ; preds = %12
%21 = load i8*, i8** %13
%22 = tail call i32 @perror(i8* %21)
%23 = load i32, i32* @EXIT_FAILURE
%24 = tail call i32 @exit(i32 %23)
unreachable
25: ; preds = %12, %25
%26 = call i32 @gettimeofday(%struct.timeval* %3, i32* null)
%27 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), %struct.timeval* %3, i32 4)
%28 = call i32 @mq_send(i64 %18, i8* %4, i32 4, i32 1)
%29 = call i32 @sleep(i32 1)
br label %25
}